Static and dynamic separation
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. In terms of implementation separating movement 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 programs;
- Another way is to mix together the dynamic with static files released 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 ideal for resources that change infrequently (if frequently updated files, is not recommended to cache Expires).
We set up here 3d, represents an access within three days of this URL, send a request to the server than the last file update time does not change, it will not crawl from the server returns a status code 304, if modified, the direct re-download from the server returns a status code 200.
Ready to work:
Two new files in the / Users / acton_zhang / software / data folder to store static resources:
- WWW (storage html): where placed in a a.html
- image (stored pictures): In which put a timg.jpeg
Configuration Nginx:
Browser Access: localhost / image /
Because the configuration of the autoindex, so the file list:
click on the link, display pictures:
Browser Access: localhost / www / a.html
Show page content: