ruby - rails 怎么清除浏览器的资源缓存?
PHPz
PHPz 2017-04-21 10:55:55
0
2
637

一rails项目 现在有一问题:我修改了这个swf文件的参数后。页面加载的是上一个swf文件,例如:
1:有一个 attack.swf 文件要在这个页面中预览
2:发现attack.swf中一些元素的位置x,y不正确。
3:于是我在页面中修改了这些参数,用程序打包后再次生成attack.swf
4:然后刷新见面。
这个时候我发现我修改的参数并没有起作用,国为浏览器加载的是上一个swf文件没有加载我新打包的文件。我清除浏览器的缓存后刷新就可以看到我新修改的swf文件。
问:有没有什么方法在rails 中清除这些缓存呢?

PHPz
PHPz

学习是最好的投资!

reply all(2)
洪涛

This actually has nothing to do with RAILS.
Mainly the configuration of the website's resource server, which may be Apache/Nginx or the ones that come with ruby.
You can imitate the way ruby ​​handles resource files. If the swf changes, change the name to avoid caching problems

小葫芦

Go check out Rails’ Asset Pipeline http://guides.rubyonrails.org/asset_p...

Rails will add a parameter to your static resources, attack.swf?t=12
Once it is detected that your static resources have changed, this parameter will change to attack.swf?t=13

You can also refer to this method. The principle is that the browser thinks that your resource is new and will reload it.
Otherwise, it will always be 304 Not Modified, and the browser cache will be too troublesome.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!