Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor gidomanders

    (@gidomanders)

    If you want to be able to modify cached content, you should use Page Cache Disk: Basic and fragment caching, which is built to allow dynamic content and still partly cache the pages.

    Thread Starter ionutm

    (@ionutm)

    thanks for responding
    i am using the disk cache i just need a action, filter, etc to programmatically modify the content before is cached

    Plugin Contributor gidomanders

    (@gidomanders)

    There is no specific filter or action for that. The cache is built upon GET request. A page is requested, the page is built the normal WordPress way, the result is stored in a cache file or in memory (depending on what method you use). The page is cached as a visitor will see the website. If you want some dynamic content to have something like products you viewed before, you should use fragment cache as that part of the page will not be cached. Fragment cache is something like this:

    
    <!--mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> -->
    echo 'The time is '.date( 'H:i:s', time() );
    <!--/mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> -->
    

    where YOUR_CODE is defined in your wp-config.php file and should be something unique so hackers will not be able to use it.

    Thread Starter ionutm

    (@ionutm)

    i need to change some strings right before the cache is saved.
    the strings are not dynamic so i don’t need to modify the output every time just when the cache changes.

    i want o change every rel="stylesheet" to rel="preload" as="style" onload="this.rel='stylesheet'"

    Plugin Contributor gidomanders

    (@gidomanders)

    You should use a filter or action to modify the output of the enqueued styles. You just want to change the result of the page, even if W3 Total Cache is disabled. This is not really related to the Page Cache.

    Thread Starter ionutm

    (@ionutm)

    if i change it before W3 Total Cache does it’s job i lose the concatenation/minification done by the plugin and i don’t want that.

    i need to modify the content after the plugin did his job.

    Plugin Contributor gidomanders

    (@gidomanders)

    Now I understand your problem clearly. We do not have a filter or action to modify this. I’ll discuss this with the team and come back to you ASAP.

    Thread Starter ionutm

    (@ionutm)

    thanks a lot ?? sorry if i was not clear from the start

    Plugin Contributor gidomanders

    (@gidomanders)

    @ionutm It’s been a while, sorry for that. I recently was asked for a similar feature and we came up with this:

    Use add_filter('w3tc_pagecache_set', 'callback'); where the callback will receive the HTML output as first parameter and must return the modified output. This filter is called just before we store the output in a cache file.

    Note that this is only applicable if you’re using Page Cache, but I assume you do.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘modify final output’ is closed to new replies.