SiteTidy
Home /Tools /Apache Cache Header Generator

Apache Cache Header Generator

Leverage browser caching by generating optimal mod_expires directives for your .htaccess file.

Apache Cache Header Generator

Generate optimal `.htaccess` browser caching configurations instantly.

Cache Durations

.htaccess

Why use Browser Caching?

Every time a user visits your website, their browser has to download all the assets (HTML, CSS, JS, Images). By configuring cache headers using Apache's mod_expires, you tell the browser to store certain files locally for a specific amount of time. On subsequent visits, the browser will load these files from its local disk instead of fetching them over the network. This dramatically speeds up page load times and reduces server bandwidth.

What is "Cache Busting"?

If you set your CSS to cache for 1 Year, returning visitors won't see your design updates for a whole year! To solve this, you use Cache Busting. When you update your CSS file, you change its name in the HTML link (e.g. from style.css to style.v2.css or style.css?v=2). The browser sees a "new" URL, fetches the fresh file, and then caches it for another year. If you use cache busting, it's highly recommended to set CSS/JS caches to 1 Year.

The Vary: Accept-Encoding Header

When caching is enabled, intermediate proxy servers or CDNs might try to cache the responses. If you compress your assets using Gzip or Brotli, you need to tell these proxies that they should serve different cached versions based on what compression algorithms the user's browser supports. The Vary: Accept-Encoding header achieves exactly this.

Related Guides

Deepen your understanding with our expert articles.