• Resolved korneelwever

    (@korneelwever)


    Hey,

    I have an idea where we perhaps could use the CloudFlare headers to utilise the htaccess version of the caching.

    I think we can to use the key of the country for the cache location, but in order to do so, the htaccess has to be customised to something like this (on all the rules of SuperCache:

    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/{%CF-IPCountry}/index-https.html.gz -f
    RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/{%CF-IPCountry}/index-https.html.gz" [L]

    Do you think that would work? It would only work for ALL countries I think, maybe more complexities can be added later.

    I’d be happy to help out on the code & testing !

    https://www.ads-software.com/plugins/country-caching-extension-for-wp-super-cache/

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’d really love to see this feature integrated into this plugin too!

    Plugin Author wrigs1

    (@wrigs1)

    Apologies for late response. Somehow I unsubscribed for emails from this support forum – now rectified.

    Your suggestion is great, but it is not as simple as it seems (see below). It might be possible using WPSC’s “wp_cache_served_cache_file” filter (mentioned below).
    It would be many hours work to investigate the feasibility and add the suggested option. I’m happy to add to my to-do list but it may be 6 months/year before anything happens.

    @korneelwever if you want to have a go in the meantime, then get in touch (via the contact page on wptest.means.us.com)

    Goal (simplistic): if “somepage.PHP” is requested by a visitor from USA then use htaccess to efficiently serve the cached page “/cache-dir/somepage-US.HTML” without the need for any PHP/WP scripts to run.

    Problems/Issues/possible Solution:

    WPSC will only allow plugin extensions to intercept and override what is uniquely cached (e.g. by country) in legacy mode. This in itself would not prevent “direct” serving of cached pages via htaccess.

    However, in legacy mode the filename used for the cached file is an MD5 “hash” so “/some_cat/some_page.php” (as generated for a US visitor) might be stored as “/cache-dir/wp-cache-0d7a305c74941f7ddde3d9b180ef6040.php”. Unfortunately, as far as I am aware, there is no way for htaccess to rewrite/regex the requested URL to an MD5 “hash”.

    That said;
    the country caching extension currently hooks into WPSC with “wp_cache_key” filter to append the country code to the “filename” before it is MD5’d and saved.

    there is also a “wp_cache_served_cache_file” filter, I’ve yet to check but this may allow the country caching extension to make WPSC use this extensions generated filenames instead of MD5 ones.

    If that is possible then we also need to consider htaccess – off the top of my head I think WPSC generates about 30 lines of rules to cater for admin users etc – this extension would need to do similar.

    Plugin Author wrigs1

    (@wrigs1)

    Marked as resolved (no response to my response after one week, and it is only a request for additional features anyway)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘htaccess cache w/ CloudFlare’ is closed to new replies.