afurnisstap
Forum Replies Created
-
Forum: Plugins
In reply to: [WP REST Cache] Where to add custom domain codeExcellent. Thank you so much for getting this out so quickly. Good job!
Forum: Plugins
In reply to: [WP REST Cache] Where to add custom domain codeGreat, thanks @acato. All understood.
A filter hook to set the max age would be great if possible.
Forum: Plugins
In reply to: [WP REST Cache] Where to add custom domain codeI just re-published/updated the page and now it’s appearing in the Endpoint API Caches list! I will update once I know if it resolves the issues given to me by page speed tests…
Forum: Plugins
In reply to: [WP REST Cache] Where to add custom domain codeAhh I see!
OK, so I can see a few entries in the Endpoint API Caches list such as:
/wp-json/acf/v3/pages/38
/wp-json/acf/v3/pages/7
/wp-json/acf/v3/pages/285And the response in Postman does have the
X-WP-Cached-Call
header for these requests so it is working to an extent but the example I gave previously (/wp-json/acf/v3/pages/1611) is nowhere to be seen and theX-WP-Cached-Call
header is not present for that one. Is there some condition not being met that means some are cached but some aren’t?One further question regarding what you’ve said about not setting the max-age – will this mean that page speed tools like https://www.webpagetest.org/ and Google PageSpeed won’t recognise that the item is being cached? That’s the main reason I’m doing all of this so I’d hope for the caching to be picked up by those tools! Currently https://www.webpagetest.org/ is telling me:
FAILED – (1 seconds) – https://domain.com/wp-json/acf/v3/pages/1611
…which I’m guessing is based off the max-age?
- This reply was modified 6 years ago by afurnisstap.
Forum: Plugins
In reply to: [WP REST Cache] Where to add custom domain codeExcellent! Thank you Acato!
With your help I’ve managed to make some progress and have found functions.php in my theme. I copied you FAQ code from the link I previously provided and changes ‘posts’ the ‘pages’ for my use case.
/** * Register the /wp-json/acf/v3/pages endpoint so it will be cached. */ function wprc_add_acf_pages_endpoint( $allowed_endpoints ) { if ( ! isset( $allowed_endpoints[ 'acf/v3' ] ) || ! in_array( 'pages', $allowed_endpoints[ 'acf/v3' ] ) ) { $allowed_endpoints[ 'acf/v3' ][] = 'pages'; } return $allowed_endpoints; } add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_add_acf_pages_endpoint', 10, 1);
I have added this at the top of functions.php and saved the file. I’m still getting max-age=1 when sending a GET request to a page URL such as /wp-json/acf/v3/pages/1611 though (I have set the Cache timeout setting in Settings > WP REST Cache to 1 hour). Any ideas where I’m going wrong?
- This reply was modified 6 years ago by afurnisstap.