How to preload cache after publishing a post?
-
I want to make the post caches (including AMP) to be preloaded immediately after publishing.
I’ve tried the Preload Fullpage Cache plugin, but LiteSpeed doesn’t cache its requests.So I tried with my own code and the problem is the same. Even though the request is sent, after visiting the given post, the header
x-litespeed-cache: miss
is returned.I experimented with headers, trying for example to set User Agent as LiteSpeed Crawler, but it did not help.
Any ideas what to do to make it work? I don’t know why LiteSpeed doesn’t cache such requests.add_action( 'save_post', function ( int $postId, WP_Post $post ) { if ( $post->post_type !== 'post' || $post->post_status !== 'publish' || wp_is_post_revision( $post ) ) { return; } $args = [ 'type' => 'GET', 'headers' => [ 'Accept: image/webp,*/*', 'User-Agent: lscache_runner' ] ]; $permalink = get_permalink( $post ); $postRequest = $args; $postRequest['url'] = $permalink; $ampRequest = $args; $ampRequest['url'] = $permalink . 'amp/'; Requests::request_multiple( [ $postRequest, $ampRequest ] ); }, 900, 2 );
Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
- The topic ‘How to preload cache after publishing a post?’ is closed to new replies.