Support » Plugin: Custom Stock Widget » Avoid caching

  • Hi, I’m using W3 Total Cache and I want to avoid caching of this plugin. So I try to implement fragment caching by puting the code in stock_widget_display.php between <!– mfunc W3TC_DYNAMIC_SECURITY –>any PHP code<!– /mfunc W3TC_DYNAMIC_SECURITY –>. This action gives an error which states that namespace declaration must be first in the .php file.
    Can you please inform how can we avoid caching of this plugin?
    Thanks.

    https://wordpress.org/plugins/custom-stock-widget/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Relevad

    (@relevad)

    Hi there,

    I put in a feature request for us to figure this out. We’ll update here.

    Plugin Author Relevad

    (@relevad)

    Initial review.

    If using a namespace declaration it must be the first statement of php code in the file.
    http://php.net/manual/en/language.namespaces.definition.php
    “A file containing a namespace must declare the namespace at the top of the file before any other code”

    Therefore you cannot simply wrap the entire php file in the
    <!– mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> –>
    tags.
    We do not yet know the best place to put those tags in or in how many files of our plugin they would need to be attached to.

    I found this documentation:
    http://justinsilver.com/technology/wordpress/w3-total-cache-fragment-caching-wordpress/
    Which says removal of <?php ?> tags from the codeblock to be fragment cached is required.

    If you come up with a working solution before we do, please let us know and we’ll incorporate it in a future release.
    Otherwise the feature request has been added to our queue.

    It would be a very good update.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Avoid caching’ is closed to new replies.