0

Is it possible to create a basic single page web page which doesn't get stored into a users browser cache?

Or

Is it possible to create a basic single page web page which deletes itself from the users browser cache?

I understand that such a page can't be fool proof because the user could simply take a screenshot to capture the data on the web page.

oshirowanen
  • 15,297
  • 82
  • 198
  • 350
  • 3
    The best approach to this is to serve appropriate [`cache-control` headers](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9). And yes, if someone decides to cache or keep a copy of the data you've served, there's little you can do about it. – James Thorpe Sep 11 '15 at 14:37
  • possible duplicate of [Using tags to turn off caching in all browsers?](http://stackoverflow.com/questions/1341089/using-meta-tags-to-turn-off-caching-in-all-browsers) – user1666620 Sep 11 '15 at 14:47

1 Answers1

0

Compliant browser (like all major browsers Chrome, FF, IE, Safari) will respect cache control headers and not cache page when instructed so.

Turning off caching should be done by sending following header with response:

Cache-Control : no-cache

Since pages cached by url you can effectively remove page from cache by sending new version with appropriate headers (assuming browser actually requests one).

Caveats:

  • intermediate servers (proxy, CDN) may have different rules, also again compliant proxies will not cache pages marked with "private", "no-cache" or "no-store" cache control header.
  • if older version of the page did not specify cache control header that prevents caching then request to the same page may not reach server as it can be served from local browser cache or proxy/CDN cache.

Note that some browsers (very old versions of most browsers and still active versions of IE) may also look at <meta> tags (like <meta http-equiv="cache-control" content="no-cache" />) to not cache the page but this behavior is not defined in the specification and should not be relied upon. More links/discussion in this question: Using <meta> tags to turn off caching in all browsers?.

Community
  • 1
  • 1
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179