“Leverage” browser caching is actually how browsers dealing with their resources. This has been instructed by google webmaster to all browsers.
If you have tested your webpage ever for speed and found out that you need to set leverage browser caching, then here is way to do it.
To enable browser caching you need to edit your HTTP headers to set expiry for certain types of files. Open your Cpanel / User hosting account and Find your .htaccess file in the root of your domain. This file is a hidden file but should show up in FTP like FileZilla . You can edit the .htaccess file with notepad or any basic text editor.
In htaccess we will set our caching parameters to tell the browser what types of files to remember. The below code tell the browsers , what to remember and how long it should remember. Setting a time duration for expiry is really very important. Because if you think your web page is updated a week then you must set cache parameters not more than a week. This is because user’s browsers will then load the cached content but exactly your web display new content and updated files. so setting a time period for cache expiry is indeed very important.
## EXPIRES CACHING ##
Common caching issue explained by example
If we set
ExpiresByType image/jpg "access 1 year" to images, it means images will be cached for one year. Remember that this mean if you change images in your website they will never be seen by all users. This is because the visitors will see the cached version of images , means those images which they have visited previously. Visitors having first visit to your website will see the latest updates , but once they visit , images will be stored in cache for 1 year. So here we just assumed 1 Year only as an example.