Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com

This Blog is protected by DMCA.com

huuphan.com. Powered by Blogger.

Leverage browser caching for Nginx

In this tutorial, How to configure Leverage browser caching for nginx.

What does Leverage browser caching mean?

Page load times can be significantly improved by asking visitors to save and reuse the files included in your website.

  • Reduces page load times for repeat visitors
  • Particularly effective on websites where users regularly re-visit the same areas of the website
  • Benefit-cost ratio: high
  • Access needed

You should add that inside of an existing server block. For example, I will add that inside server block /etc/nginx/sites-enabled/default file.

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
   
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            add_header Cache-Control "public, no-transform";
            expires         7d;
    }
}

You can test speed up site On GTmetrix



post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com