HTML - Cache control max age

后端 未结 4 1059
梦毁少年i
梦毁少年i 2021-02-12 14:55

I\'ld like to present always the latest website content to the user but also have it fast loaded. By researching I came across postings people suggesting to use the cache for sp

4条回答
  •  名媛妹妹
    2021-02-12 14:59

    There is more than one way to do this - but you need to consider exactly what you need to cache and what you don't. The biggest speed increases will likely come from making sure your assets (css, images, javascript) are cached, rather than the html itself. You then need to look at various factors (how often do these assets change, how will you force a user to download a new version of the file of you do change it?).

    Often as part of a sites release process, new files (updated files) are given a new filename to force the users browser to redownload the file, but this is only one approach.

    You should take a look at apache mod_expire, and the ability to set expiry times for assets using the .htaccess file.

    http://www.google.com/?q=apache+cache+control+htaccess#q=apache+cache+control+htaccess

提交回复
热议问题