Sales: 0844 88 43 400 (9am til 5pm GMT, Mon - Fri)

Tudásbázis

How To Implement Browser Side Caching Nyomtatás

  • 14

Implementing browser side caching tells your website visitors web browser to cache certain files in its cache for a pre-set period of time rather than fetching them from the server on each visit. This is another simple thing you can implement to increase page load times.

To do this, you just need to open up your .htaccess file (it’ll be in the document root of your website) and add the following code to the top of it:

## EXPIRES 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 text/css "access 1 month"
 ExpiresByType text/html "access 1 month"
 ExpiresByType application/pdf "access 1 month"
 ExpiresByType text/x-javascript "access 1 month"
 ExpiresByType application/x-shockwave-flash "access 1 month"
 ExpiresByType image/x-icon "access 1 year"
 ExpiresDefault "access 1 month"

## EXPIRES CACHING ##

As you can see from the above code, it tells your visitors web browser to cache image files (.jpg, .jpeg, .gif and .png) for 1 year and CSS and HTML for 1 month. You can change any of these values as you see fit, but these tend to work fine for most sites.

TIP: If you are using the cPanel File Manager to add the code, you will first need to tweak the settings so that you can view hidden files. To do this, open up File Manager and click on the "Settings" link in the top right of the page. Then check the box that says "Show hidden (dot) files".


Hasznosnak találta ezt a választ?

« Vissza