Skip to content

Turning off caching using .htaccess

Caching improves website performance by storing files in a visitor’s browser. However, during development or troubleshooting, you may want to disable caching so changes are reflected immediately. On ruachost.com, you can control caching behavior using the .htaccess file.

  • Ensure visitors see the latest version of your site.
  • Prevent browsers from serving outdated files.
  • Useful when testing new designs, scripts, or content.
  1. Log in to your hosting account via FTP, SFTP, or File Manager.
  2. Navigate to your site’s root directory (public_html).
  3. Open or create the .htaccess file.

Insert the following code at the bottom of the .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>
<FilesMatch "\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|mp3|mp4|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 "Thu, 1 Jan 1970 00:00:00 GMT"
</IfModule>
</FilesMatch>
  • Save the .htaccess file.
  • Clear your browser cache.
  • Reload your site to confirm changes are applied.