21 October 2014

Forcing Not Read The Browser Cache

Many people browse the Internet, but few know the existence and support provided by "caches" for Internet browsing, and thanks to them we get a much quicker to some services access and also save resources in most cases .

Theoretically, according to Wikipedia a cache is a storage area dedicated to the retrieval of frequently used data at high speed , but really a cache goes beyond and more in the area of Internet.

The browsers keep a cache with static files downloaded from the websites: images, HTML pages , CSS files , javascript files , etc...

Forcing Not Read The Browser Cache
Forcing Not Read The Browser Cache


It is usually beneficial browser cache because the user will get a much faster load website after accessing the website for the first time , and server resources will save bandwidth and process by not having to spend the same files again and again.

But when you're developing a website or making modifications , can the browser cache bother us, because it may be that they can not see the changes instantly.

Using some simple HTML tags you can force to the visitor's browser does not note the browser cache, it is also useful when we have a website that is very updated and the browser cache difficult for us to process.

All we have to do is enter one of the following tags in the HEAD , ie, between the tag <HEAD> tag and </ HEAD> :


<Meta http-equiv = "Expires" content = "0">
<Meta http-equiv = "Last-Modified" content = "0">
<Meta http-equiv = "Cache-Control" content = "no-cache, mustrevalidate">
<Meta http-equiv = "Pragma" content = "no-cache">


With this, the client browser will no longer take into account the cache you saved earlier.

In WordPress , to add room tags in the HEAD must edit the template or theme , namely we must edit the "header.php" file where the tags <HEAD> and </ HEAD> from which we get one of the above lines .

You can also force an application developed in PHP to not save browser cache, so we must use the following code in the PHP file loaded:

<? Php
header ("Cache-Control: no-cache, must-revalidate"); // HTTP / 1.1
header ("Expires: Sat, July 1, 2000 05:00:00 GMT"); // Date in the past
?>

This will be sure that the cache is reset on all Web browsers and proxy http visit the site.

If you have a problem with the browser cache on your web site or want to implement browser cache correctly on your project , Contact Us today and we'll tell you.

Labels: , ,