user3925697
user3925697

Reputation: 619

Update only one file via application cache

Here is my manifest.appcache file.

CACHE MANIFEST
app.js
theme.css
logo.png

How can I force browser renew the app.js file only?

Upvotes: 0

Views: 298

Answers (2)

agoodthought
agoodthought

Reputation: 37

I had a same or similar situation to this.
I needed the browser to refresh the cache of file index.html.
And I could only see it refreshed when in incognito mode, which was not helping me much...
except for understanding why I wasn't seeing my file's update...

Anyway, what helped me was like the following:

  1. Make backup of specific file that needs refreshing
  2. Delete file in project
  3. Run web application (without the file)
  4. Return file to project, and then run application

For me, this worked.

I hope it will help others as well.

Upvotes: 0

micwallace
micwallace

Reputation: 480

Application cache works slightly different to what you may think.

When a new version of the manifest becomes available, the browser goes through all the files and determines which have changed on the server. The browser does this by sending the "If-Modified-Since" header with the request.

If the file hasn't been modified, the server will return code 304 (not modified) and the browser will skip the download and move to the next file.

Only files that have been modified get refreshed.

It's also a good idea to include a version or hash in the manifest, so a new manifest is always downloaded and checked.

In example, I use a php script to dynamically generate my appcache.manifest. The script md5's all the included files to produce a hash/version number that's included in the manifest.

Upvotes: 2

Related Questions