Skip to content

Instantly share code, notes, and snippets.

@petergus
Forked from hans2103/.htaccess-mod_headers
Created August 26, 2018 02:08
Show Gist options
  • Select an option

  • Save petergus/5e7a85a71634f4ee6c11d889c508f43c to your computer and use it in GitHub Desktop.

Select an option

Save petergus/5e7a85a71634f4ee6c11d889c508f43c to your computer and use it in GitHub Desktop.

Revisions

  1. @hans2103 hans2103 created this gist Apr 13, 2015.
    35 changes: 35 additions & 0 deletions .htaccess-mod_headers
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    <IfModule mod_headers.c>
    Header set Connection keep-alive

    # Cache-control headers
    # 2 HOURS
    #<filesMatch "*">
    Header set Cache-Control "max-age=7200, must-revalidate"
    #</filesMatch>

    # 480 weeks - 290304000
    # 2 WEEKS
    <filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|swf)$">
    Header set Cache-Control "max-age=1209600, public"
    </filesMatch>

    # 1 DAY
    <filesMatch "\.(css)$">
    Header set Cache-Control "max-age=86400, public, must-revalidate"
    #Header set Cache-Control "max-age=0, public, must-revalidate"
    </filesMatch>

    # 2 DAYS
    <filesMatch "\.(xml|txt)$">
    Header set Cache-Control "max-age=172800, public, must-revalidate"
    </filesMatch>

    # 2 HOURS
    <filesMatch "\.(html|htm)$">
    Header set Cache-Control "max-age=7200, must-revalidate"
    </filesMatch>

    <FilesMatch "\.(gif|jpg|png|ico|css|js|pdf|txt)$">
    Header append Cache-Control "public"
    </FilesMatch>
    </IfModule>