Examples of static and dynamic separation configuration Nginx-

Nginx static and dynamic separation is simply to separate dynamic with static requests can not be understood as just a simple static pages to dynamic pages and physical separation. Strictly speaking it should be dynamic with static requests separate request, it can be understood as using Nginx handling static pages, Tomcat handle dynamic pages. Static and dynamic separation from the current point of view to achieve roughly divided into two types, one is the purely static files into separate independent domain name, on a separate server, is currently the mainstream respected program; Another way is dynamic with static files published mixed together, to separate by nginx. Specify a different suffix to achieve different requests forwarded by location. By expires parameter settings, you can make the browser cache expiration time, reduce traffic and requests before the server. Expires specific definitions: a resource is to set an expiration time, that is to say without having to go to the server to verify, confirm directly through the browser itself has expired can be, so it will not generate additional traffic. This method is very suitable resources do not often change. (If you frequently updated files, is not recommended to cache Expires), I set up here 3d, represents access the URL within three days, send a request to the server than the last file update time does not change, not from fetch server returns a status code 304, if modified, re-downloaded from the server 200 returns a status code.

Experiment Code

   

1.
Project Resource ready
2
be configured nginx
find
nginx installation directory, open /conf/nginx.conf configuration file,

 

 

Add the listener port, access to name
a focus on adding
location
last check Nginx configuration is correct can then test whether the static and dynamic separation is successful, the need to remove the back-end tomcat
a static file on the server, see if you can visit, if you can still access instructions nginx resources directly back
, do not go back-end server tomcat

Guess you like

Origin www.cnblogs.com/XiangHuiBlog/p/12014841.html