• Trying to implement geotargeting without losing the benefits of caching, I found this discussion very helpful.

    Following one of Donncha’s suggestions, I wrote a plugin of my own (although based on the very nice Visitor Country by Izhaki) to set up a supercache_filename_str cache action, in the hope of thereby obtaining one set of cache files per country. E.g., index.html would be replaced by index-SE.html, index-US.html etc.

    Turning on the debugging feature, I was happy to see that WP Super Cache now checked for index-SE.html, rather than index.html. However, the newly generated file was still saved as index.html.

    The problem seems to have been that the function supercache_filename in wp-cache-phase1.php calls apply_filters rather than do_cacheaction once the previous function is available. This is normally fine, since supercache_filename_str is converted into a filter by the function wp_cache_phase2 in wp-cache-phase2.php. However, my addition to supercache_filename_str was not.

    To get my plugin working, I therefore edited wp_cache_phase2.php, adding

    global $wp_supercache_actions;

    at the top and replacing

    add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );

    by

    foreach($wp_supercache_actions['supercache_filename_str'] as $key => $action)
    	add_filter( 'supercache_filename_str', $action);

    To my great joy, this seems to have solved my problem!

    If the above addresses a real issue with WP Super Cache, and isn’t just some sort of misunderstanding on my part, feel free to include it (or another, better solution) in a future release.

    Best regards,

    Erik Nordblad,
    Stockholm, Sweden

    https://wordpress.org/plugins/wp-super-cache/

  • The topic ‘Additions to "supercache_filename_str" action not applied; proposed fix’ is closed to new replies.