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



Comments

Popular posts from this blog

zimbra some services are not running [Solve problem]

Bash script list all IP addresses connected to Server with Country Information

Zimbra Client host rejected Access denied fixed