No caching in HTML5
Asked Answered
B

3

7

In HTML4 we used stuff like

    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
    <meta http-equiv="Expires" content="Thu, 01 Jan 1970 00:00:00 GMT" />

to get the browser to not cache the pages.

What should I use in HTML5 to get the browser not to cache my pages. I don't want any pages at all cached.

I've seen something about

    <html manifest="example.appcache">
      ...
    </html>

but it seems like a lot of work to specify all the pages in the whole web application just to get the browser not to cache anything.

Is there a simpler way?

If I omitt the manifest part from the html tag, will that make the browser not cache anything? I.e.

    <html>
      ...
    </html>

Or will it take that as an ok to cache everything?

Buckley answered 29/8, 2013 at 15:13 Comment(1)
The manifest specifies settings for the application cache - a very cool new feature of HTML5 but it has nothing to do with what you are attempting. I'd stay away from using it for now. My own experience has shown it to be not quite ready for prime time.Bowlds
T
4

Answer#12693786 might be helpful.

Here is an example of your-manifest-file to force updates to all resources.

CACHE MANIFEST
NETWORK:
*

and append manifest attribute to <html> element.

<html manifest="your-manifest-file">

Required for all HTML files you want to disable cache.
Can not be avoided because it is specification of HTML5.

Turney answered 4/6, 2014 at 7:42 Comment(1)
Beware, this Cache Manifest feature has been removed from the Web standards.Telephone
B
2

Cache settings are optimally handled by the response headers from the web server. I would research changing those settings. Including a header like:

Cache-Control: max-age=0,no-cache,no-store,post-check=0,pre-check=0

will stop all chaching in my experience. I have never had consistent desired behavior setting cache behavior using meta tags in any version of HTML.

Bowlds answered 20/11, 2013 at 18:15 Comment(1)
in php header("Cache-Control: max-age=0,no-cache,no-store,post-check=0,pre-check=0"); on top of your scriptHepta
N
0

I think if you leave out the manifest attribute, it defaults to no cache. I know that on firefox, you can use add-on tools like Firebug or HttpFox to check if the page is cached. Not sure about other browsers, but most likely it's under "Network" tab of developer tools.

Northrup answered 20/11, 2013 at 18:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.