Don't allow webbrowser to cache your website - heres how

6 posts Page 1 of 1
Contributors
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Don't you hate it when you make an update on your website and because web browsers cache websites/web pages users who go on your website will not see the updates?

In the <head> of your HTML file you can add this code:
Code: Select all
<meta http-equiv="pragma" content="no-cache">
That will tell the browser to not cache your website, every time you make an update to your website/web page the user who visits the website will see it because they won't see cached web pages :)
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Great snippet, but for those who don't know, this will make page loading slower.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Yes it will but if you have a website that is updated alot and you need the pages to be loaded again and not from cache then this is how its done
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

If you want to cashe certain images, files, etc:

Replace your beginning html tag with this...
Code: Select all
<html lang="en" manifest="offline.manifest">
Now make sure you make a file called "offline.manifest" (without quotes) in the same directory/folder your index.html file is located.

Inside the offline.manifest file you'd add the following (replace my file names with the ones you want to cashe)
Code: Select all
CACHE MANIFEST
index.html
abstract.css
grayscale.css
images/mikebg.png
images/abstractbg.png
images/chrome.png
images/android.png
images/teambg.png
images/chrome-bg.png
images/cloud.png
images/firefox.png
images/safari.png
images/ie9.png
images/ipad.png
images/lin.png
images/mac.png
images/opera.png
images/win.png
images/dot-tk.gif
images/swagbucks.jpg
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

mikethedj4 wrote:
If you want to cashe certain images, files, etc:

Replace your beginning html tag with this...
Code: Select all
<html lang="en" manifest="offline.manifest">
Now make sure you make a file called "offline.manifest" (without quotes) in the same directory/folder your index.html file is located.

Inside the offline.manifest file you'd add the following (replace my file names with the ones you want to cashe)
Code: Select all
CACHE MANIFEST
index.html
abstract.css
grayscale.css
images/mikebg.png
images/abstractbg.png
images/chrome.png
images/android.png
images/teambg.png
images/chrome-bg.png
images/cloud.png
images/firefox.png
images/safari.png
images/ie9.png
images/ipad.png
images/lin.png
images/mac.png
images/opera.png
images/win.png
images/dot-tk.gif
images/swagbucks.jpg
Thanks Mike!
I was just about to ask for this part. cooll;
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

You're very welcome :)
6 posts Page 1 of 1
Return to “Tutorials”