Robot Portal

Easily manage all aspects of your account | Knowledgebase |

Knowledgebase

Disable caching with .htaccess

Quick .htaccess snippet to disable browser caching by modifying Cache-Control, Pragma, and Expires headers. Strictly plug-n-play.

Just add the following directives to your site’s root .htaccess file:

# DISABLE CACHING
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>

No editing required. I use this technique on several of my sites and it works like a charm. You can verify that it works using any number of freely available online tools, and/or any browser extension that displays header/server response.

Updates

Update #1: Here is another line that you can play with:

Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"

Update #2: Here is another technique for caching static resources while optimizing performance (You can customize the list of file types to suit your specific needs)

<FilesMatch "\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|png|pdf|swf|txt)$">
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>
<IfModule mod_headers.c>
FileETag None
Header unset ETag
Header unset Pragma
Header unset Cache-Control
Header unset Last-Modified
Header set Pragma "no-cache"
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Expires "Mon, 10 Apr 1972 00:00:00 GMT"
</IfModule>
</FilesMatch>

  • 23 Users Found This Useful

Was this answer helpful?

Related Articles

500 Internal Server Error

Internal Server Error help, 500 error Internal server errors can be caused by a few different...

Do you provide AwStats?

Yes, we provide AWSTATS most of the servers of HostSEO Networks and it is updated automatically...

Register_Global ON?

Since register_globals is disabled on the servers for security purposes, some of your scripts and...

Unable to Access my site?

We receive lots of queries from our client saying that why i'm not being able to access my site....

How to change a php.ini value?

We use suPHP in all of our servers. So you can modify your php.ini value very easily! All you...

Born in 2004 ... Trusted By Clients n' Experts

SEO Stars

They never made me feel silly for asking questions. Help me understand how to attract more people and improve my search engine ranking.

Read More

Emily Schneller Manager at Sabre Inc
SEO Stars

Took advantage of Hostseo's superb tech support and I must say, it is a very perfect one. It is very fast, servers reliability is incredible.

Read More

Leena Mäkinen Creative producer
SEO Stars

We're operating a worldwide network of servers with high quality standards requirements, we’ve choose hostseo to be our perfect partner.

Read More

Ziff Davis CEO at Mashable
SEO Stars

It’s very comfortable to know I can rely about all technical issues on Hostseo and mostly that my website and emails are safe and secured here.

Read More

Isaac H. Entrepreneur
SEO Stars

With hostseo as a hosting partner we are more flexible and save money due to the better packages with great pricing, free SEO n' free SSL too!

Read More

Madeline E. Internet Professional