how to cache css, images and js?

前端 未结 6 2157
攒了一身酷
攒了一身酷 2020-12-13 03:01

I would like to have images, css, and javascript cached client-side on their browser when they load up a web page. There are so many different types of caching I am confused

6条回答
  •  再見小時候
    2020-12-13 03:27

    This is best done in IIS or in your config file - make sure your CSS/JS/images are set to never expire.

    When you reference them from your code, I suggest appending a version or build-date to the filename, e.g. script.js?20100120, so that when you do come around to changing them, you just need to change the version to force a refresh from all the browsers that have cached it.

提交回复
热议问题