Created
June 3, 2025 14:17
-
-
Save WesleySmits/2505d456ede4cad95ed8a26fe32ab93b to your computer and use it in GitHub Desktop.
.htaccess code to cache static resources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Turn on Expires and set default to 0 | |
| ExpiresActive On | |
| ExpiresDefault A0 | |
| # Set up caching on media files for 1 year (forever?) | |
| ExpiresDefault A29030400 | |
| Header append Cache-Control "public" | |
| # Set up caching on media files for 1 week | |
| ExpiresDefault A604800 | |
| Header append Cache-Control "public" | |
| # Set up 2 Hour caching on commonly updated files | |
| ExpiresDefault A7200 | |
| Header append Cache-Control "proxy-revalidate" | |
| # Force no caching for dynamic files | |
| ExpiresActive Off | |
| Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform" | |
| Header set Pragma "no-cache" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment