Leveraging Browser Cache on Nginx

Leverage browser Cache is process of making the browser cache resources by the exertion of force by means of a lever, which is the server.

Advert

Leverage browser take the literal meaning of making the browser cache resources by the exertion of force by means of a lever, which is the server. Although process of caching differs based on the server you use ( Nginx, Apache, etc .) the concept remains the same all over, server only changed content or download what has changed.

Caching settings are to be done in the sites configuration file, it's not possible to set the caching inside a directory like in Apache.

Open the configuration file for the domain inside /etc/nginx/sites-available, if you use the default configuration then it's default file.

Open it up in your favorite editor. Now inside the server block insert the following code.

location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}

If you use multiple sites add this into the configuration file of each and make sure to give the nginx a restart. You have the lever set to cache :D

Comments

Wow ! you have someting to tell us. That's great! Please keep in mind that comments are moderated, we employ rel="nofollow" for links, avoid using a spammy word or a domain in name field, it might end up as a Spam. Thanks for reading.

Last 5 Articles

All Articles >

  1. Domain Authority

     
  2. Public Endpoint in Django Rest Framework

     
  3. 4 Ways to Increase Conversion Rates using Videos

     
  4. Getting the best customer experience analytics solutions

     
  5. How to Remove an App from Django Project

     

News Letter

Subscribe to our email newsletter for useful tips and valuable resources, sent out every new article release.