NO BUG: Query Load Conflict with Caching

I noticed an issue today with the query load functionality. I have a simple load more button on my blog page. When in admin mode, it works fine. When I have WP Fastest Cache & Redis Object Cache applied, it prints the following error to console when the Load More Button is clicked
image

How do I fix this conflict?

Thanks

Hey,
so just to confirm.

If you don’t have any plugin enabled, it works. If you enable only WP Fastest Cache & Redis Object Cache, then it shows this error.

Is that correct?

@Matej - No, if I have them enabled, but in admin mode, it works. Once I look at it incognito mode and they are cached, then I have the issue

Those two plugins allow me to meet Google Page Speed’s draconian requirements

I don’t really have deep knowledge about those two plugins, but I suggest you narrow the problem down to one plugin, and then try to change the settings of that plugin so that it will not block our request anymore.
You will have to play with settings a bit though.

First, which one of those plugins is causing the problem? Then I can try it also in my install, since the error is 403 - rest_cookie_invalid_nonce, which I would like to replicate locally.

Best regards,
M

Hi @lynxm,

I checked a bit more and I can see this error, like I stated before.

It looks like the nonce generated by WP already expired and is not allowed to access the rest API.
Can you please check if you can reduce the caching time in your cache plugin to maybe 8 hours, and that may solve the issue.
More info about caching lifespan here: Nonces and Cache Lifespan - WP Rocket Knowledge Base

Please let me know if that solved the issue.

Best regards,
M

Interesting. I see that the premium version of WP Fastest Cache has a timeout /refresh feature.
Their site is down at the moment, but once back up, i’ll try that and see if it works.

However, if WP has a nonce refresh time of 24 hours, are you suggesting 8 hours because that miminizes the amount of time they’re out of sync?

I think this is good article about this: Cache Lifespan - WP Rocket Knowledge Base
It’s for WP Rocket, but I believe it applies to WP Fastest Cache also.

Setting it to 8h for example, basically makes it sure that the page cache will be refreshed in the span of 24h, which is nonce refresh time.

Best regards,
M

I talked with the WP Fastest Cache team.

The problem is caused by the WordPress nonce security system. To resolve this issue, you should add a cache timeout as below.

Wordpress Nonce Cache

Yeah, that’s it then, like I have written above. Setting it to 8h (or in this case 10h) helps.

I’ll mark this as a NO BUG.

Thanks;
M

1 Like

Thanks for your help!

I confirmed its now working after making the timeout change

Perfect,
thank you for reporting back.

M