如何在IE中停止缓存js文件? [英] How do I stop js files being cached in IE?
问题描述
我创建了一个使用 CKEditor javascript丰富编辑控件的页面。
I've created a page that uses the CKEditor javascript rich edit control.
这是一个非常巧妙的控制,特别是因为它是免费的,但是我对它允许你添加模板的方式有严重的问题。
It's a pretty neat control, especially seeing as it's free, but I'm having serious issues with the way it allows you to add templates.
要添加模板,您需要修改CKEditor模板文件夹中的模板js文件。描述它的文档页面是这里。
To add a template you need to modify the templates js file in the CKEditor templates folder. The documentation page describing it is here.
在我想要更新模板或添加新模板(或任何其他需要我修改js文件的模板)之前,此工作正常。
This works fine until I want to update a template or add a new one (or anything else that requires me to modify the js file).
Internet Explorer缓存js文件但不接受更新。清空缓存允许更新,但这不是一个可接受的解决方案。每当我更新模板时,我都不想告诉整个组织的所有用户清空他们的IE缓存。必须有更好的方法!
Internet Explorer caches the js file and doesn't pick up the update. Emptying the cache allows the update to be picked up, but this isn't an acceptable solution. Whenever I update a template I do not want to tell all of the users across the organisation to empty their IE cache. There must be a better way!
有没有办法阻止IE缓存js文件?或者这个问题有另一个解决方案吗?
Is there a way to stop IE caching the js file? Or is there another solution to this problem?
更新
好的,我在CKEditor API中找到此部分,这将允许我使用几个人建议的将时间戳插入网址解决方案。
Ok, I found this section in the CKEditor API that will allow me to use the "insert timestamp into the url" solution suggested by several people.
所以脚本现在看起来像这样:
So the script now looks like this:
config.templates_files =
[
'/editor_templates/site_default.js?time=' + utcTimeMilliseconds
];
感谢您的帮助。
推荐答案
您可以将rand种子添加到js文件中。我的意思是< script src ='jsFile.js?seed = 12345'
每次要清空缓存 - 更改种子数
You can add rand seed to your js file. I mean <script src='jsFile.js?seed=12345'
And every time you want to empty cache - change seed number
更新:
因为我知道你必须像这样写 config.templates_files = [ '/mytemplates.js?seed=12345'];
as I understood you have to write like this config.templates_files = [ '/mytemplates.js?seed=12345' ];
这篇关于如何在IE中停止缓存js文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!