Overview
In order to let browsers explicitly know to keep a copy parts of your website, you can set content-expiry headers within nginx. This means that subsequent page loads or revisits within the expiry time, the browser doesn't have to reload these files. This is best set for static media (ie CSS files, images and similar), which can in most instances be safely cached.
Instructions
- Login to your Plesk server and select the domain you wish to set the content expiry headers for.
- Under the domain, select "Apache and nginx settings":
- In the bottom "Additional nginx directives" field, add the following:
location ~* .(?:ico|css|js|gif|jpe?g|png|svg|woff)$ { expires 30d; add_header Pragma public; add_header Cache-Control "public"; }
This sets all icons, css, js, images and fonts to cache for 30 days.
- Click OK to save and apply.
You can verify these headers are now working by using your browser's debug tools or a third party website such as GTMetrix.