• Around line 1363 in plugins/w3-total-cache/PgCache_ContentGrabber.php, adding a filter there could allow for creative repurposing of $key (the page cache key)

    For example, I need to vary the cache by the country code based on GeoIP. Adding this in manually (hack) works perfect so far I can tell. It would be great if there was a proper way to do this without hacking the plugin. I hunted everything I could and it looks like there is a way to alter the key but only if filtering is happening, which it is not in this case.

    $key .= ‘_’ . $_SERVER[‘HTTP_GEOIP_COUNTRY_CODE’];

    I don’t see any issue with adding this in, only possible benefits and creative ways to utilize the cache even better (could even override it with the user’s ID, or any other headers, $_SERVER/$_ENV, etc, if page caching makes sense based on that dimension!)

    I would have submitted a PR if there was a git repo, but it looks like it’s still back on SVN?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello,

    There is a line in PgCache_ContentGrabber.php:
    $this->_page_key = apply_filters( 'w3tc_page_extract_key',
    So you can use add_filter('w3tc_page_extract_key', ...);
    Please note that it will slow down disk-enhanced without modification of htaccess/nginx rules.
    Also, you need to enable “Late caching:” which Overwrites key of page caching via custom filters by postponing entry extraction during the init action.

    Thread Starter mike503

    (@mike503)

    pgcache.engine is “file_generic” because it’s set to page enhanced. it looks like that causes “late caching” to be disabled. why would that be? I have modified the nginx rules and it works, but requires hacks to nginx.conf and the plugin at the moment. I’d like the plugin not to need to be hacked; I can’t determine how to make that happen, isn’t page_enhanced the only option for nginx/server level bypassing of PHP execution?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Request: add_filter for page cache key’ is closed to new replies.