ios - Prevent UIWebView to cache JavaScript files? - Stack Overflow

I have a UIWebView that loads html, css and javascript.When ever I do a change in the html or css, that

I have a UIWebView that loads html, css and javascript.

When ever I do a change in the html or css, that is applied ones I reopen the WebView. But my JavaScripts seems to be cached, changes in them dosen't get visbile when reopen the WebView.

What am I missing here?

I have a UIWebView that loads html, css and javascript.

When ever I do a change in the html or css, that is applied ones I reopen the WebView. But my JavaScripts seems to be cached, changes in them dosen't get visbile when reopen the WebView.

What am I missing here?

Share Improve this question asked Jan 12, 2012 at 10:50 user920041user920041
Add a ment  | 

2 Answers 2

Reset to default 4

This answer helped me: Prevent caching of .css files in UIWebView loaded from disk

Basically, you just need to add an incrementer as parameter to the link like ?version=1 or ?time=12345678. For example: <script src="myscript.js?version=123></script>

For a dynamically loaded javascript I'm using:

script.src = "myscript.js?version="+new Date().getTime();

and the script is updated properly, without the version parameter the file is cached in the UIWebView.

I suspected UIWebView caching as well. Initially. But the actual problem was with Xcode treating .js files as pilable sources - Xcode puts them into a "Compile Sources" build phase (project targets -> Build Phases tab) whereas they should be in "Copy Bundle Resources" phase. Whatever piler think about the .js file, it does not detect the change and replace it when changed. Moving my .js file from pile phase to copy resources phase fixed the problem nicely.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745178245a4615298.html

相关推荐

  • ios - Prevent UIWebView to cache JavaScript files? - Stack Overflow

    I have a UIWebView that loads html, css and javascript.When ever I do a change in the html or css, that

    4小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信