Skip to content

Instantly share code, notes, and snippets.

@WesleySmits
Created June 3, 2025 14:17
Show Gist options
  • Select an option

  • Save WesleySmits/2505d456ede4cad95ed8a26fe32ab93b to your computer and use it in GitHub Desktop.

Select an option

Save WesleySmits/2505d456ede4cad95ed8a26fe32ab93b to your computer and use it in GitHub Desktop.
.htaccess code to cache static resources
# 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