Leverage browser caching

Notes: Leverage browser caching
Firstly, make sure you have the mod_expires module enabled in your httpd.conf file. It should be enabled but just check to be sure.

This block of code is usefully included your .htaccess file and sets the expiry to be a year from the date of delivery to the browser. There are nuances about what the expiry time is (expiry starts at delivery or is started from the date of creation of the asset) but a year is going to be good in most cases

Then copy this into the .htacess of your site and restart or reload your httpd/apache2 server

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg “access plus 1 year”
ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType text/css “access plus 1 month”
ExpiresByType application/pdf “access plus 1 month”
ExpiresByType text/x-javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 year”
ExpiresDefault “access plus 2 days”
It works nicely for my servers so it might work for yours too. As ever, all risk is your own. Credits: https://gtmetrix.com/leverage-browser-caching.html