Nginx_ time to define the cache of static pages

Nginx modify the configuration file, define the cache time for static pages

proxy ]# vim /usr/local/nginx/conf/nginx.conf

server {

         listen 80;

         server_name localhost;

         location / {

                        root html;

                        index index.html index.htm;

                        }

         location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {

                            30d the Expires ;             // define the client cache for 30 days

                            }

         }

Proxy ] # cp / usr / report this content share / Backgrounds / Day . jpg   / usr / local / nginx / HTML / jpg copy a file to a web directory

proxy ]# /usr/local/nginx/sbin/nginx -s reload

Firefox HTTP # : //192.168.4.5/day.jpg       // After optimization, using the Firefox browser to access the image to view the cache information

End.

 

Guess you like

Origin www.cnblogs.com/liusingbon/p/11119348.html