Forum Moderators: open

Message Too Old, No Replies

How to set an expiry date to use browser caching

         

lzr0

8:27 pm on Aug 21, 2014 (gmt 0)

10+ Year Member



Hi,
Google's page speed insights recommends setting an expiry date or a maximum age for static resources (images, js) to load previously downloaded resources from browser cache.

I understand you need to control the server to do it. Is there any way to do in html if I don't have a server (i.e. just use shared web hosting)?

not2easy

10:29 pm on Aug 21, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If your shared hosting is hosted on a server running Apache, you can edit the .htaccess file to control file compression and caching. There are different ways to do this, so it sort of depends on your skill level and what you want to prevent and permit caching for - the file types.

If a type of file is not frequently changed, such as images or css files, you can set longer expiration terms. File types that can change frequently need short expiration terms so the browser will get the latest version.

You can read more about the different ways to cache content here: [httpd.apache.org...]

You can find some example code there for the different ways and more help in the Apache Forum here: [webmasterworld.com...] if you hit a wall.

lzr0

12:53 pm on Aug 22, 2014 (gmt 0)

10+ Year Member



not2easy,

Thank you. I am going to dig in .htaccess usage.