I converted a plain vanilla HTML page to HMTL5/CSS3 with a responsive layout, and for security reasons (dictated by the security people) the page must never cache.
The page previously used <meta http-equiv="Pragma" content="no-cache">
and <meta http-equiv="Expires" content="-1">
to prevent the page from being cached.
What replaces this in HTML5? How do you prevent an html page from caching in the client?
I've spent a week reading about manifest files, but they seem to do exactly opposite of what I want as attaching a manifest file explicitly causes the page it is attached to to cache.
And please don't refer me back to the w3c definition of which meta elements are now allowed — I understand that HTML5 does not include the cache-control
or Pragma
in meta
elements.
I need to know what it does include that will prevent a page from being cached.
Here's how... When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache.
HTTP-EQUIV META tags Pragma: no-cache prevents caching only when used over a secure connection.
In the beginning of code you need to use this:
<!DOCTYPE html> <html manifest="manifest.appcache"> ...
Then create manifest.appcache
with such content:
CACHE MANIFEST # Cache manifest version 1.0 # no cache NETWORK: *
I dislike appcache a tremendous amount. It almost works well but can be a real unforgiving pain. While doing some code refactoring, I realized that after logout, i could browse back to the the last page. Of course, refreshing browser it would force user back to login but this is not desired.
After searching around and seeing the options, I started to get a bit frustrated. I do not want to use appcache. I then realized that my code was redirecting to login page after destroying the session and got an idea, what if, I redirect to the home page instead? And voila, page was loaded, session checked (and of course not there), user redirected to login. Problem solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With