Leverage Browser Caching
What is browser caching?
Downloading a website might require multiple requests between the client and server which may lead to slower processing times. It may also increase the data cost of the user when they visit a website.
By asking users to opt for browser caching, the loading time of your web pages can be improved significantly.
Why leveraging browser caching?
When you leverage browser caching you can expect the following benefits:
A reduced page load time for repeat visitors.
Effective on websites where users generally return to the same area of the website frequently
Saves the web server bandwidth.
Browser caching works by storing some of the files locally in the browser being used by the user. The first time a user accesses a web page, it takes some time to load, but then next time he visits the same website or even a different page on the same website, the page loads faster as the files needed are already stored locally.
For instance, the logo of your website doesn't change frequently. So, if you were to cache the log file locally to a browser, it would save time when a user revisits the website since the page will not have to download the logo image file again.
How to leverage browser caching?
You can enable browser caching by making changes to the HTTP headers and adjusting the expiry times for specific file types.
You can find the .htaccess file in the root of your website's domain, and it should be visible in an FTP client. This file can be edited using any basic text editor.
ExpiresByType image/jpg "access plus 1 year"
ExpiresDefault "access plus 2 days"
You can change the expiry type depending on how frequently your files are updated.
While leveraging browser caching it is important to keep in mind that you do not set the expiry time for too long since users may not get the most updated version of your website.