Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » HTML Codes / HTML-CSS-PHP-JavaScript » How To Control And Disable Browser Cache And Cookies With HTML?

How To Control And Disable Browser Cache And Cookies With HTML?

You probably see words cache and cookies on daily basis. When you visit a website for the first time, your browser saves (caches) pieces of this site. That’s why every time you click Back or Forward, your browser doesn’t need to pull fresh files from a server.

Caching is a useful yet surprisingly complex feature of web browsers. In this article, we’ll explain how the browser uses its cache to load pages faster, which factors determine cache duration, and how we can bypass the cache when necessary.

Caching and cookies are two methods browsers employ to save data regarding a certain website. Caching is used to store some web page data locally for faster loading on each subsequent revisit, whereas cookies are small pieces of data containing important user information for a website. Not many webmasters know or use this, but you can actually use just HTML meta tags to control cookies and browser caching for your website!

Meta Tags are used to store pieces of information on a web page. Essentially, it is information about data, and its purpose is for browsers and search engines to understand and know the page better.

Table of Contents

What Are Browser Cache?

The browser cache is used for storing website data like HTML, CSS, JavaScript, and images. Caching is a method of storing data that can be used later. Like other programs that you may have installed, browsers use caching to store website data on your computer instead of requesting the data from a web server to make web pages load faster.

What Are Browser Cookies?

Browser cookies are different from the cache; Instead of making web pages load faster, they instead store text information like preferences and favorites.

Why Is Caching Important?

All browsers attempt to keep local copies of static assets in an effort to reduce page load times and minimize network traffic.
Fetching a resource over a network will always be slower than retrieving it from the local cache. This is true whether the server is on the same network or it’s located on the far side of the world.

How To Control And Disable Browser Cache And Cookies With HTML?

When you visit a webpage, your browser stores it in its cache so as to make reloading faster. Sometimes, cache errors cause the browser to load an older version of a page, even when new content is available. To prevent this, you can simply disable the browser cache from time to time by using some meta tags. Here’s what you can do.

<meta http-equiv="Cache-Control" content="no-store" />

This meta tag is recognized in Firefox, Chrome, and Internet Explorer. Even more so in IE, where you can use more values and specifications to disable caching, as follows.

<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />

You can also set an expiration date to ensure that the browser will show the file that’s fresh from the server, rather than from the cache. The document expires after the specified date and time. “0” means the browser has to check for a fresh document on each visit.

<meta http-equiv="expires" content="Fri, 18 Jul 2014 1:00:00 GMT" />

How To Set Auto Expreable Cookies?

Cookies are small files stored on your browser that contain important user information, such as user and password. Websites may reuse the cookies to tailor some functionality. For example when you shop in an online store, as long as you have not yet checked out, the items remain in your cart even though you have left the browser for several days.

Recommended For You:
Disable Up-Down-Left-Right Scrolling In TouchScreen

Here’s the tag for setting a cookie;

<meta http-equiv="Set-Cookie" content="name=data; path=path; expires=Day, DD-MMM-YY HH:MM:SS ZONE">

name=data is the name of the cookies which determines the values set in it. path is the path of document. Whereas, the value of expired indicates the time and date when cookies are deleted from your computer. If you leave the expired date empty, the cookies will be deleted once you quit the browser. Here is a an example cookie that will expire at the end of this year;

<meta http-equiv="Set-Cookie" content="name=data; path=path; expires=Thursday, 01-Jan-2015 00:00:00 GMT">

Got any more useful HTML tricks you can share with us? Let us know in the comments section below!

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

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