/wp-json/ missing in REST API URL
-
Good morning,
when I enable the plugin, ajax requests via WP REST API do not work, because the plugin cuts off the string/wp-json/in the url.
It should behttps://domain.com/wp-json/wp2/…. instead it ishttps://domain.com/wp2/
How do I solve this? is there a bug?
-
Hi @stefacchio,
Could you provide more details about the problem? Where has the
/wp-jsonpart been removed? removed in cached results? or general?Hi @m_uysl, mmmh I didn’t understand exactly your question.
When I enable the plugin with all enabled such as page cache, file css and js optimization, all blocks that do a fetch request with WP REST API, use the url without /wp-json/ getting a 404 error.
Instead with plugin deactivated the fetch url is correct with /wp-json/ and all work fine.See following images
Could you share the link to the page you see this problem? If you prefer to not share publicly feel free to share via email (support[at]poweredcache[dot]com)
I think the problem is caused by deferring, https://share.cleanshot.com/f3xHF7D0
Disable defer for wp-api resources and try again. (probably your site makes the requests for relative path /wp/….` when the base url is not set before making ajax calls.
I developed the block, in the code I use a relative path as per the wordpress documentation.
I wanted to benefit as much as possible by using the defer on each script… are there alternatives I can implement to not disable the defer?
To disable the defer only on bees what should I enter in the defer field?If Powered Cache is adding defer, you can enter
wp-api(.*)in the exclusions. This allows you to disable defer for specific resources, so you can still benefit from it on others. Generally, deferring inline scripts can cause issues, so I suggest double-checking to avoid breaking any functionality on your site.Ok perfect. Thank you so much.
I noticed another problem with plugin.After disable it, When I reactive the plugin the notification appears activated, but actually remains deactivated. In order to reactivate it, I have to deactivate and reactivate another plugin, after which powered cache is also activated
You’re welcome, and if you’re happy with the plugin, I’d greatly appreciate it if you could leave a review.
After disable it, When I reactive the plugin the notification appears activated, but actually remains deactivated. In order to reactivate it, I have to deactivate and reactivate another plugin, after which powered cache is also activated
I’m not totally sure if I’ve got this right 🙂. But object caching is often the usual suspect here — if it’s enabled, try purging it to clear out any stale data.
I confirm, the problem is related to the object cache. Can’t you add a hook that empties the cache when you deactivate the plugin? It is really frustrating as a problem. Also, could you add a button that deactivates all the cache types in the plugin, but without deactivating the plugin? Or some sort of developing mode.
-
This reply was modified 1 year, 6 months ago by
Stefano.
Can’t you add a hook that empties the cache when you deactivate the plugin?
Not with hook, but technically we can drop the cache before unlinking object cache drop-in, however, this would not be an ideal decision for busy websites.
It is really frustrating as a problem.
Caching is a frustrating problem in general.
Also, could you add a button that deactivates all the cache types in the plugin, but without deactivating the plugin? Or some sort of developing mode.
I could, but I’d prefer not to add that — at least for now. You can use bypass functionality when testing pages: https://docs.poweredcache.com/bypass-functionality-in-powered-cache/
-
This reply was modified 1 year, 6 months ago by
The topic ‘/wp-json/ missing in REST API URL’ is closed to new replies.