• t3chtr3ndz

    (@t3chtr3ndz)


    hi I am using google pagespeed which informed that my posts / resources are not using maxium age for various resources. Here’s the message

    Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.

    So I decided to add the following in /domainname/.htaccess file

    <IfModule mod_expires.c>
        ExpiresActive on
        ExpiresByType text/css "access plus 60 days"
        ExpiresByType text/javascript "access plus 60 days"
        ExpiresByType image/ico "access plus 60 days"
        ExpiresByType image/jpg "access plus 60 days"
        ExpiresByType image/jpeg "access plus 60 days"
        ExpiresByType image/gif "access plus 60 days"
        ExpiresByType image/png "access plus 60 days"
        ExpiresByType text/css "access plus 60 days"
        ExpiresByType text/html "access plus 60 days"
    </IfModule>

    When I try to write this file and refresh my site, W3 Total Cache plugin overwrites the .htaccess file back to it’s original state

    # BEGIN W3TC Browser Cache
    <IfModule mod_deflate.c>
        <IfModule mod_headers.c>
            Header append Vary User-Agent env=!dont-vary
        </IfModule>
            AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
        <IfModule mod_mime.c>
            # DEFLATE by extension
            AddOutputFilter DEFLATE js css htm html xml
        </IfModule>
    </IfModule>
    # END W3TC Browser Cache
    # BEGIN W3TC CDN
    <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
    </IfModule>
    </FilesMatch>
    # END W3TC CDN
    # BEGIN W3TC Page Cache core
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^(.*\/)?w3tc_rewrite_test/?$ $1?w3tc_rewrite_test=1 [L]
        RewriteCond %{HTTP:Accept-Encoding} gzip
        RewriteRule .* - [E=W3TC_ENC:_gzip]
        RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
        RewriteRule .* - [E=W3TC_PREVIEW:_preview]
        RewriteCond %{REQUEST_METHOD} !=POST
        RewriteCond %{QUERY_STRING} =""
        RewriteCond %{REQUEST_URI} \/$
        RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
        RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
        RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
    </IfModule>
    # END W3TC Page Cache core

    I am not quite sure what to do.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter t3chtr3ndz

    (@t3chtr3ndz)

    Can someone tell me how do I resolve this?

    Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.

    Thanks

    Willie Jackson

    (@williejackson)

    My email reply bounced back, so I’ll reply here:

    You don’t need to edit the .htaccess file manually, W3 Total Cache can manage all of your caching policies.

    For the snippet of code in question, you just need to configure browser caching in W3 Total Cache.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: W3 Total Cache] redirect error’ is closed to new replies.