Back to Top

To prevent caching in web browser

To prevent caching in web browser

If any information is critical to your website and if you want to remove out of date contents and want to prevent web browsers from caching your page from first place.

Solutions

There are two possible ways with that we can solve this problem

  1. With use of HTML meta tag.
  2. With HTTP headers

Let’s have a look of both ways:

1. With use of HTML meta tag.

The most useful and basic way to prevent page caching is HTML meta tag.

SYNTAX:

With the inserting a date we can tell the browser that the cached copy of the page is out of date and after that we have written “no-cache” so the browser will not cache the page.

no-cache with meta tag is not much feasible solution because Browser first loads the page and read meta tag and if tag did not get when page was first requested by browser, browser will keep cached copy as original.

Let’s look at the alternative solution.

2.Using HTTP Headers

One of the better ways is to use the HTTP protocol itself with the use of PHP header function which is same as the two HTML meta tags given above.

The HTTP protocol gives guarantees that no web browser or proxy server will cache the page, so users will always receive the latest content.we can say this is the best way to ensure a page is not cached. But for some cases, The Cache-Control and Pragma headers will catch content and expire doesn’t work like if the date is set incorrectly in user’s machine.

You also like other post, see here:

To set Expire Headers using .htaccess
Browser Detection with Joomla

Comments (1)

  1. no-store will truly not store in browser. we recently ran into a problem w/ no-cache not executing javascript that needed to be run on page load

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to move Modx site to Live server

Posted on 12 years ago

Bhumi

How to create Cron jobs in WordPress?

Posted on 11 years ago

Bhumi

How to create zoho leads using PHP?

Posted on 10 years ago

Bhumi

How to clean HTML content in PHP?

Posted on 10 years ago

Bhumi