How to Set Up Non-cached Pages with .htaccess Christopher MaioranaUpdated on August 16, 2021 1 Minute Read Cache control is one of the primary system administrative tasks you will find yourself performing. Thankfully, most browsers will take care of at least some of the caching for you, remembering certain resources that were loaded before. However, there may be occasions in which browser caching is something you don’t want. In this article, we’ll show you how to set up non-cache pages with .htaccess. For example, if you’re developing a site in a test environment and making constant changes, cached resources will likely interfere with changes you’re making. You may find yourself constantly clearing your browser cache to see the effect of your work. Or, imagine you have a static page that is updated frequently, like a client roster, or an organizational document. In cases like the latter, it would not be convenient for your visitors to constantly clear their browser caches or risk missing out on new information. Set up non-cached pages with .htaccess Using your favorite file management method, open your .htaccess file for editing Option tip: using SSH, you can use an editor command like nano .htaccess to use the nano text editor Place this code into your .htaccess file: <filesMatch "\.(html|htm|js|css)$"> FileETag None <ifModule mod_headers.c> Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" </ifModule> </filesMatch> Remember that this .htaccess file will act recursively upon all files within the document path that follows. So it would be best to separate this path from any resources you want to cache. For example, a subdomain would be a great place to put this code in order to set up non-cache pages with .htaccess. Share this Article CM Christopher Maiorana Content Writer II Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog. More Articles by Christopher Related Articles How to Set Up Cloudflare with InMotion Hosting Intro to Migrating your WordPress Site Data Migrating your WordPress Database Migrating WordPress Files Configuring WordPress After a Migration Testing your WordPress website after Migration How to Move WordPress from a Subfolder to the Root Directory What to expect during a mass server migration Move Your WordPress Site to a New Server Moving Websites Built with Older Technology into WordPress