Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmod编译后的JS模板,老是被浏览器缓存,如何解决? #75

Closed
pannysp opened this issue Jan 15, 2015 · 3 comments
Closed

Comments

@pannysp
Copy link

pannysp commented Jan 15, 2015

开发阶段,配置设置cache为false,更新了模板代码,监听后也重新编译了模板JS,但浏览器还是缓存原来的模板JS文件,我觉得是不是当cache为false时,异步请求模板JS地址后面加个时间戳,这样就不会让浏览器缓存啦。上线后再改回来,如何?

@aui
Copy link
Owner

aui commented Jan 15, 2015

你可能混淆了概念,tmodjs 编译后的只是一个普通的 js 文件,你要处理的应该是浏览器的设置、或者给 js 文件加时间戳等一系列方式避免缓存

@pannysp
Copy link
Author

pannysp commented Jan 15, 2015

我明白,我只是举个解决办法。浏览器的设置一般都是缓存同名文件,所以想加时间戳来解决。但时间戳应该是在template.js里配置,因为我普通的 js 文件模板是通过你template异步读取,template.js也是你这个tmod编译出来的,所以编译出来的template.js代码里应该有个判断,如果要加时间戳,则:模板路径/js模板名+‘?当前时间或随机数’,这样来异步加载模板文件吧

@pannysp
Copy link
Author

pannysp commented Jan 15, 2015

不好意思,我搞错了。是requireJS加载的,我错了,-_-!!

@aui aui closed this as completed Jan 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants