• I want share this tip for use w3 page cache for requests with ignorable query strings. In this case, request with utm_source, utm_medium, utm_term, utm_content, utm_campaign and gclid parameters used the cache.

    # BEGIN custorewrite
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteRule ^ – [E=CustomQueryString:%{QUERY_STRING}]

    RewriteCond %{ENV:CustomQueryString} ^(.*)&?utm_source=[^&]+&?(.*)$ [NC]
    RewriteRule ^ – [E=CustomQueryString:%1%2]

    RewriteCond %{ENV:CustomQueryString} ^(.*)&?utm_medium=[^&]+&?(.*)$ [NC]
    RewriteRule ^ – [E=CustomQueryString:%1%2]

    RewriteCond %{ENV:CustomQueryString} ^(.*)&?utm_term=[^&]+&?(.*)$ [NC]
    RewriteRule ^ – [E=CustomQueryString:%1%2]

    RewriteCond %{ENV:CustomQueryString} ^(.*)&?utm_content=[^&]+&?(.*)$ [NC]
    RewriteRule ^ – [E=CustomQueryString:%1%2]

    RewriteCond %{ENV:CustomQueryString} ^(.*)&?utm_campaign=[^&]+&?(.*)$ [NC]
    RewriteRule ^ – [E=CustomQueryString:%1%2]

    RewriteCond %{ENV:CustomQueryString} ^(.*)&?gclid=[^&]+&?(.*)$ [NC]
    RewriteRule ^ – [E=CustomQueryString:%1%2]

    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 %{ENV:CustomQueryString} =””
    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 custorewrite

    https://wordpress.org/plugins/w3-total-cache/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tips for use cache for request with query string’ is closed to new replies.