Enable Leverage browser caching using the .htaccess file for Apache

Leverage browser caching is a cache mechanism for page speed. Most of the static files that are used on web pages can be saved on the computer of your visitor for future access. Every time a visitor accesses a page on your website these files will then be accessed from the visitor’s computer instead of your website, which will significantly speed up page load times.

Fetching resources over the network is both slow and expensive: the download may require multiple roundtrips between the client and server, which delays processing and may block rendering of page content.

Google recommends a minimum cache time of one week and preferably up to one year for static assets, or assets that change infrequently.

We prefer using the first code to enable leverage browser caching!

You can enable leverage browser caching for Apache or NGINX add one of the codes hereunder to the .htaccess file:

 

Second option

If the above code doesn’t works try this one:

Note: you can add or remove certain file types from the above examples if you don’t or do want to use it.

If you enable leverage browser caching the next step is: gzip compression

Check this article on what to add to your .htaccess file to compress or deflate your web page on the server before it is delivered to the visitors browser which will decompress it and save up to 90% time: Enable gzip compression using the .htaccess file for Apache