Skip to main content

Stop Browser Caching using Meta Tags

Browsers typically cache the page it has visited to save on bandwidth and load time. This means that when you hit the back button, the browser will use its locally stored page instead of requesting the page again from the server.



You may not want browsers to cache pages in several instances such as for online forms where credit card or personal details are viewable. Another instance is when you’re trying to password protect web pages when using scripts such as Simple Authorization Script.
To stop browsers from storing a version of your web page in its cache, use the meta tag, Pragma:No-Cache, that is,

<meta http-equiv="PRAGMA" content="NO-CACHE">
This meta tag needs to be included between the head tags of your html page.
<html>
<head>
<meta http-equiv="PRAGMA" content="NO-CACHE">
</head>
<body>


Unfortunately, the Pragma:No-Cache meta tag is not 100% bug free. Work arounds are needed for Internet Explorer and Internet Explorer 5 as its caching mechanism is a little “special” and extra code is required.

Work Around for Internet Explorer

For Internet Explorer, you would need to add another set of head tags that contains the Pragma:No-
Cache meta tag between </body> and </html>. This means you would have 2 sets of head tags, one at the top of the page and one at the bottom of the page.

<html>
<head>
<meta http-equiv="PRAGMA" content="NO-CACHE">
</head>
<body>

AND
</body>
<head>
<meta http-equiv="PRAGMA" content="NO-CACHE">
</head>
</html>


Work Around for Internet Explorer 5

For Internet Explorer 5, you would need to add an additional Expire:-1 meta tag, that is, <meta http-equiv=”EXPIRES” content=”-1″> along with the Pragma:No-Cache meta tag. Both meta tags need to be included at the top and bottom of the page as with the work around for Internet Explorer.
<html>
<head>
<meta http-equiv="PRAGMA" content="NO-CACHE">
<meta http-equiv="EXPIRES" content="-1">
</head>
<body>

AND
</body>
<head>
<meta http-equiv="PRAGMA" content="NO-CACHE">
<meta http-equiv="EXPIRES" content="-1">
</head>


Popular Posts

Top 10 PHP Frameworks for Web Developers

PHP: Hypertext Preprocessor is a popular general-purpose scripting language that is especially suited to web development. PHP is the world’s most popular scripting language as it is fast and reliable. Almost all of the popular blogs and websites were powered by PHP. A PHP Framework provides a basic structure for which to build the web application. It will make the development easier and saves a substantial amount of time and effort for the developers as well as speed up the development process. The list below is  10 of the best PHP Framework for Web Development. Laravel Symfony Laminas Project (Zend Framework) CodeIgniter Yii 2.0 CakePHP Phalcon FuelPHP PHPPixie Slim The top 5 are Laravel , Symfony , Laminas Project , CodeIgniter and Yii 2.0 . 1. Laravel Laravel is a web application framework with expressive, elegant syntax and follows the model–view–controller (MVC) architectural pattern and based on Symfony. Laravel attempts to take the pain out...

Top Hybrid App Development Frameworks 2020 for Developers

Hybrid application s are web applications that run in the device like the native apps. They are typically written in HTML, CSS, and Javascript. Hybrid apps run code inside a native container and use the device browser engine to render HTML and javascript. Hybrid apps allow developers to build applications to different mobile platforms in a single codebase. Here is the list of the top Hybrid App Development Frameworks. React Native Ionic Flutter Xamarin PhoneGap JQuery Mobile Corona Framework 7 Mobile Angular UI Appcelerator Titanium Our top 5 are React Native , Ionic , Flutter , Xamarin, and PhoneGap . 1. React Native React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces. Use a little—or a lot. You can use React Native today in your existing Android and iOS projects or you can create a whole new app from scratch. React Native brings React’s declarative UI framewor...