Support » Plugin: Autoptimize » WordPress nonce 403 error

  • Resolved Veminom

    (@veminom)


    Hi! Can you please tell how can I decrease the expiration time of Cache? Currently, it is more than the expiry time of WordPress nonce which is creating problems on my website.

    Is there any setting using which I can decrease the expiry time of the cache?

    Looking forward to your response.

    Regards,
    Premanshu

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    AO does not aggregate/ optimize inline JS with the nonce keyword in it @veminom and AO does not have a cache expiry mechanism but will automatically create new cached files if a change in JS (or CSS) is detected.

    hope this clarifies,
    frank

    Thank you for your response. We have a plugin which uses the nonce and it has an external JS with localized JS variable called ajax_nonce which stores the nonce. But it looks like the AO is caching this JS file due to which we are facing this issue. Any suggestions?

    Regards,
    Premanshu

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    that is .. surprising, as;
    * a nonce is “calculated” so dynamic
    * which is why nonces are mostly added in inline JS
    * if not in inline JS it would have to be stored in dynamic JS (so a .php-file)
    * but AO does not optimize dynamic JS (or CSS) files

    so the only way this would happen is if the plugin would re-generate a static file every x hours with a new nonce. if that is the case excluding that file should fix your problem?

    This is how we are using the nonce, It is generated in inline JS. We use the same ajax_nonce variable in the external JS.

    Please see the screenshot below:
    http://tinyurl.com/ybstpg86

    We do not want to exclude the file, the purpose of using the Autoptimize will be useless.

    Any suggestions?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    We do not want to exclude the file

    you don’t have to, Autoptimize _will_ exclude it by default

    the purpose of using the Autoptimize will be useless.

    not really 🙂

    Thank you for your response. But it looks like AO is caching the inline JS too and I’m sure about this because when my forms do not work, I just clear the cache from AO and the forms start working properly.

    We also tried generating the nonce directly and added it to the hidden field. But it did not work either. It looks like AO is caching the whole HTML? If that is the case, is there any solution to prevent/exclude just nonce from caching? Any filter or hook?

    Thank you!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    But it looks like AO is caching the inline JS too

    inline JS with “nonce” in it is never aggregated/ optimized/ cached 🙂

    It looks like AO is caching the whole HTML?

    no, AO does not do page caching

    when my forms do not work, I just clear the cache from AO and the forms start working properly

    that’s because AO tries to tell page caching plugins to purge their cache too in order to avoid HTML being cached by page caches would still refer to autoptimized CSS/ JS that is gone

    conclusion; you probably have a page cache that is caching the nonce, you’ll have to set expiry there.

    Ah yes, looks like that will resolve things.

    Can you please guide me where I can set expiry?

    Thank you for your help!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    well, that depends on the page cache (plugin?) you are using?

    Got it! I’m using WP Fastest cache and I think I found the cache expiry time setting there. Let’s see if it works properly or not. Hopefully, it should work 🙂

    Really appreciate your support.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’re welcome @veminom, feel free to leave a review of the plugin and support here! 🙂

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘WordPress nonce 403 error’ is closed to new replies.