While working on optimising your site to increase your Google’s PageSpeed Insights score, you will certainly be facing, at some point, the “Leverage browser caching” problem (see image below).
To overcome this situation, just follow these easy instructions.

Installation Specs

Cloud service: Google Cloud Platform
Server: Debian running Apache2
App: WP installed via Google click to deploy


Step #1

First, you need to enable the “expires_module” module on your server (Debian).

To do so, enter the following commands:
sudo a2enmod expires

Then restart Apache:
sudo service apache2 restart


Step #2

Copy/paste this code in your .htaccess file:
## EXPIRES HEADER CACHING ##

ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"

## EXPIRES HEADER CACHING ##