United States - EN - USD ( $ )

Knowledge Base

How to modify browser cache time

You can edit “.htaccess” file, to set CSS cache time for browsers, or you can disable cache entirely. It is generally not recommended to close the cache, as this may have a serious impact on site's loading experience.

 

How to configure

Edit “.htaccess” file, and add the following text at the end of file.

<ifmodule mod_expires.c="">
  ExpiresActive On
  # Images
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"
  # Video
  ExpiresByType video/mp4 "access plus 1 year"
  ExpiresByType video/mpeg "access plus 1 year"
  # CSS, JavaScript
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType text/javascript "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  # Others
  ExpiresByType application/pdf "access plus 1 month"
  ExpiresByType application/x-shockwave-flash "access plus 1 month"
</ifmodule>

Various expiry times can be set, depending on the specific needs, for each website document type. If certain types of files are updated frequently (e.g. CSS files), they can be set to expire at shorter times.

When setting browser cache time, please note:
    1. Establish caches for all static resources whenever possible,
    2. Configure the expiration time to at least one month (recommended setting is to add one year since the visit time),
    3. Don't set the cache to more than a year in advance.

 

Possible problems

  • When setting the browser cache time, if certain files are set too long, users may not be able to navigate to the latest version of the website page, after it has been updated.
  • If you're making changes to your website design, you may not be able to see those changes, despite the site being modified, due to browser keeping cache files for too long.

Choose your region, language and currency

Australia - English - AUD ( A$ ) European Union - English - EUR ( € ) United Kingdom - English - GBP ( £ ) United States - English - USD ( $ ) 中国大陆 - 简体中文 - CNY ( ¥ ) 香港 - 繁體中文 - HKD ( HK$ ) 台灣 - 正體中文 - TWD ( NT$ ) Hong Kong - English - HKD ( HK$ ) Worldwide - English - USD ( $ ) Worldwide - English - EUR ( € ) Changing region or currency will empty the cart [ CLOSE ]