Part 2: Cache Static Content:
Content Caching Explained: Data Caching is the process of storing data for faster retrieval. In the case of Nginx, it’s the temporary storage of web pages in order to reduce bandwidth and improve performance. When someone visits your website the cached version will be served to the visitor unless it has been modified.
Enabling Caching
Within your Nginx configuration, you can add the following to your server{} directive to tell your computer to cache the web page’s static files for faster accessibility. In the example below, we are caching .ico, .css, .js, .gif, .jpg and .png files.
location ~* \.(?:ico|css|js|gif|jpg|png)$ {
expires 30d;
add_header Vary Accept-Encoding;
access_log off;
}