0

I have a problem with manifest cache in HTML 5. Here is my manifest file:

CACHE MANIFEST
# This manifest was generated by grunt-manifest HTML5 Cache Manifest Generator
# Time: Tue Jan 13 2015 15:05:00 GMT+0100 (Central European Standard Time)

CACHE:
js/application.js
js/pdf.js
js/vendor.js
js/vendor/jquery.min.js

NETWORK:
*

SETTINGS:
prefer-online

I want cache only files in section "cache" in manifest.appcache . All others files like ajax request shouldn't be cached by browser.

Now everythink is loaded from cache, when i refresh site.

Cache chrome

What i'm doing wrong?

bordeux
  • 584
  • 1
  • 7
  • 20

1 Answers1

1

Put your js files out of the CACHE directive to explicitly cache them.

CACHE MANIFEST
# Tue Jan 13 2015 15:05:00 GMT+0100 (Central European Standard Time)

# Explicitly cached entries
js/application.js
js/pdf.js
js/vendor.js
js/vendor/jquery.min.js

# offline.html will be displayed if the user is offline
FALLBACK:
# offline.html

# All other resources (e.g. sites) require the user to be online. 
NETWORK:
*

# Additional resources to cache
CACHE:
# ...

Template taken from A Beginner's Guide to Using the Application Cache

You will also have one master entry per resource that has the manifest directive:

These are resources added to the cache because a browsing context visited by the user included a document that indicated that it was in this cache using its manifest attribute (Using the application cache).

And one for the manifest file itself.

Everything else you might see as being cached is not to do with the manifest file but normal browser caching of resources which you can bust using known cache busting techniques such as random params added to resource url.

Here is a good SO post on preventing caching of ajax resources

Community
  • 1
  • 1
Ali Habibzadeh
  • 10,137
  • 3
  • 48
  • 68
  • http://el.your-project.co.uk/manifest.appcache - here is my new appcache manifest file, so result is this same: http://i.imgur.com/hnrQEmQ.png – bordeux Jan 13 '15 at 14:55
  • http://el.your-project.co.uk/Auth?manifest=1 – bordeux Jan 13 '15 at 15:02
  • my cache in chrome has 91 items. exactly the ones you specified in your manifest here http://el.your-project.co.uk/manifest.appcache – Ali Habibzadeh Jan 13 '15 at 15:11
  • Here is my cache in chrome: https://gist.github.com/ali-habibzadeh/4c1788c05cf7969a4c94 which has your 91 explicit entries plus 1 Master which has the manifest directive and one manifest cache entiry – Ali Habibzadeh Jan 13 '15 at 15:14
  • yes. This is true, but after refresh this site, also is cached ajax requests (not included in this manifest file). Try reload website and show Auth?manifest=1 in Network tab. Status code is 200 OK (from cache) . This shouldn't be cached – bordeux Jan 13 '15 at 15:15
  • That's nothing to do with your manifest. That's the browser caching your resources. Try using ajax cache buster and other resource cache buster – Ali Habibzadeh Jan 13 '15 at 15:15
  • Cool. let me know how you get on – Ali Habibzadeh Jan 13 '15 at 15:39