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 user920041user9200412 Answers
Reset to default 4This 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
评论列表(0条)