How to Tell Browser Not To Cache your Website or Blogs

Many Webmaster don’t want Browser to cache their website for many reasons and if you also don’t want then simply use this code in your header.php file.But before you try this you must be aware that cache improve your website speed and also help you to give higher rank in google search results



How to Tell Browser Not To Cache your Website or Blogs

If you are WordPress user then you need to avoid using any cache plugin or avoid page cache Setting, because if you do this then your browser will not reflect changes immediately.

If you want to do this in PHP you can use the header function to send the appropriate HTTP headers to the browser:

header(‘Cache-Control: no-cache’);
header(‘Pragma: no-cache’);

Why to and Why not to Use cache

If your website Keep on updating content regularly and you want to show updated content in real-time then you need to use no cache for those content, you can also set time period for Cache like 24 Hour, 1 Hour etc, however you can use cache for fixed file like CSS ,JS, logo etc. This will improve user Experience when they surf your blog or website.

Improve Website Speed using 3rd Party Plugin and Website

Some 3rd party website like CloudFlare, Maxcdn, provide you option to use cache for your permanent file, If you are WordPress user then you can try using w3 total cache plugin or wp super cache plugin to improve your website speed

Advertisement