Leverage Browser Caching

.htaccess Expire Headers by filetype

google inspector browser caching toolbar

If you have access to your .htaccess and mod_expires is enabled on your Apache server there are a few lines of code you can add to cache different file types in the browser.

# BEGIN Expire headers
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/svg+xml "access plus 2592000 seconds"
ExpiresByType image/svg  "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType text/html "access plus 2592000 seconds"
# END Expire headers

By telling the browser to remember assets it has already downloaded you can reduce future http requests and improve performance as the user browses the rest of the site.

A quick test is simple – open the google inspector network tab and start browsing.