How to Enable Browser Caching in WordPress Hosted on Nginx Server

How to Enable Browser Caching in WordPress Hosted on Nginx Server

How to Enable Browser Caching in WordPress Hosted on Nginx Server-: Every time a browser loads a webpage it has to download all the web files to properly display the page. This includes all the HTML, CSS, JavaScript and images. Some pages might only consist of a few files and be small in size – maybe a couple of kilobytes. For others however there may be a lot of files, and these may add up to be several megabytes large. Twitter.com, for example, is 3 MB+.

What is Browser Caching-:

Browser caching works by marking certain pages, or parts of pages, as being needed to be updated at different intervals. Your logo on your website, for instance, is unlikely to change from day today. By caching this logo image, we can tell the user’s browser to only download this image once a week.

Every visit that user makes within a week would not require another download of the logo image. By the web server telling the browser to store these files and not download them when you come back saves your users time and your web server bandwidth. 

How to Enable Browser Caching in WordPress Hosted on Nginx Server-:

You can enable Leverage Browser Caching via the settings page of WP Fastest Cache for Apache servers but You cannot be enabled Leverage Browser Caching for the Nginx servers so you have to enable it manually. You need to add the following code into /etc/nginx/nginx.conf to enable Leverage Browser Caching on Nginx servers.

location ~* \.(css|js|ico|gif|jpeg|jpg|webp|png|svg|eot|otf|woff|woff2|ttf|ogg)$ { expires max; }
About Amar Patel 263 Articles
Hi, I am Amar Patel from India. Founder, Author and Administrator of wpknol.com. I am a Simple Average Man who Loves life and Love living life.Professionally I am a Mechanical Engineer. Apart from my Job, I Love to write the things around WordPress WordPress CMS.