How to solve the JSCSS cache problem of static Resources in the javascript-web project release

Source: Internet
Author: User
The cache has been set on the server, but the version is released. If JSCSS is modified, no version is added. If the client browser does not forcibly clear all the caches, the old cache resources are still used. How can I solve the static resource cache problem? Is YII2 using this idea? JSC is detected every time... the cache has been set on the server, but the version is released. If JavaScript CSS is modified, no version is added. If the browser on the client does not forcibly clear all the caches, the old cache resources are still used. How can I solve the static resource cache problem?

Is YII2 using this idea? Is the last modification time of the js css file detected every time?
If the file is the same as the cached file, do not regenerate it. Otherwise, the cached js css file will be regenerated?

Reply content:

The cache has been set on the server, but the version is released. If JavaScript CSS is modified, no version is added. If the browser on the client does not forcibly clear all the caches, the old cache resources are still used. How can I solve the static resource cache problem?

Is YII2 using this idea? Is the last modification time of the js css file detected every time?
If the file is the same as the cached file, do not regenerate it. Otherwise, the cached js css file will be regenerated?

The yii solution is very good. It is generally solved by adding a version number.

Let's look at the implementation of laravel. In the elixir section. The principle is to read a ing file. This file is generated by gulp.

Use gulp-rev-hash to distinguish by hash.

You can use fis3. to differentiate resource files with md5 suffixes

Md5 production abstract, used as the suffix of the file .. Gulp, grunt, or webpack can be solved in a corresponding way.

1. Version Number
2. hash naming

I suggest you look at this
Https://www.zhihu.com/question/20790576
Recommended for solutions ~ However, RoR and Django have their own solutions. yii2 is not clear.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.