In the iPad project I'm working on I've got a UIWebView
inside of the app which displays a .html file which links to a .css file, i.e.
<link rel="stylesheet" href="style.css" type="text/css">
These files are stored locally on the iPad but are fetched from a remote server. I've noticed that UIWebView
caches the .css file more or less indefinitely, and refuses to load the new file whenever I change it. I've once changed the name of the file just to get it to reset, but that's unacceptable in the long run.
Is there a way to prevent caching of the CSS file in a UIWebView
? Or even better, is there a way to say when to cache and when not to?
The better way that keeps your HTML markup and iOS code isolated is
Yes.
Change your line to this:
Every time that you update the stylesheet, change the version. The browser will think that it is a different page because of the query string, and your server will ignore it.
If you are using a server side language such as PHP, you can also do the following:
This will change the version every time you refresh, thus stopping all caching.