0

I am using the Application Cache feature and all is working well, however when I cache resources initially, I include a few pages that need to be accessible online. These pages are behind a login screen, and show the login screen instead of the actual page if the user is not logged in. So when they are cached, it's cached with the login screen.

I want to refresh my app cache after logging in / out so that it properly reflect the pages if the user's connection drops out after logging in.

I know that the cache manifest only gets called for update if the file itself actually changes, and this is posing a problem as I can't think of a way to update the file after the login / logout is called.

Unfortunately I can't use a separate cache manifest on different pages as the page is dynamically templated into the one HTML file with Mustache templates.

How can I programatically ask the browser to update my application cache after logging in / out?

joshschreuder
  • 1,413
  • 2
  • 18
  • 32

1 Answers1

3

Could you pass along an id with the manifest url?. Since the session id will change after a logout/login the browser will see the manifest as a different file although it actuall did not change.

<html manifest="myManifest.mf?id=<?= session_id() ?>">
  ...
</html>
Matt MacLean
  • 19,410
  • 7
  • 50
  • 53
  • Good stuff! My template data has a LoggedIn property that I can use to either pass as an id (eg. myManifest.mf?LoggedIn=True) or as a conditional Mustache statement to load a separate manifest file (which achieves the refresh and gives me extra flexibility in terms of caching / not caching based on whether they are logged in). Thanks! – joshschreuder Jun 27 '13 at 05:49