• I recently added some code to my .htaccess file, to improve caching and compression. Can you tell me if I have this code formatted correctly? I’m particularly wondering if I have the first 3 lines in the correct place. (Header unset Pragma, FileETag None, Header unset ETag)

    # BEGIN WordPress

    Header unset Pragma
    FileETag None
    Header unset ETag

    AddType image/x-icon .ico
    <IfModule mod_headers.c>
    # YEAR
    <FilesMatch “\.(ico|gif|jpg|jpeg|png|flv|pdf)$”>
    Header set Cache-Control “max-age=29030400”
    </FilesMatch>
    # WEEK
    <FilesMatch “\.(js|css|swf)$”>
    Header set Cache-Control “max-age=604800”
    </FilesMatch>
    # 24 HOURS
    <FilesMatch “\.(html|htm|xml|txt|php)$”>
    Header set Cache-Control “max-age=86400”
    </FilesMatch>
    </IfModule>

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    <IfModule mod_mime.c>
    AddType application/x-javascript .js
    AddType text/css .css
    </IfModule>
    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript
    <IfModule mod_setenvif.c>
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    </IfModule>
    <IfModule mod_headers.c>
    Header append Vary User-Agent env=!dont-vary
    </IfModule>
    </IfModule>

    # END WordPress

  • The topic ‘Modifying .HTACCESS for caching/compression | Formatting question’ is closed to new replies.