Wordpress LScache Plugin: How to preload cache after publishing a post?
Last Updated on: Wed, 15 Apr 2026 00:00:02 I want to make the post caches (including AMP) to be preloaded immediately after publishing. Ive tried the Preload Fullpage Cache plugin, but LiteSpeed doesnt 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 dont know why LiteSpeed doesnt 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 ) Expand This topic was modified 9 months, 1 week ago by Rafal Calka. POST requests are not cached by default and must be enabled on server level, but in your case this isnt possible with POST caching. LScache caches by URL request, so you must request the URL of published post first to get it cached. A request can be done in several ways and can also be done with cURL. If you have published a post, WP must be extended to send cURL request in backend of WP. But this is only one of more ways how could it be done. POST requests are not cached by default @CacheCrawler But its GET request. Request is correct and does what you described. It doesnt matter if request is GET or POST. A new post must be requested first before it can be cached. @CacheCrawler And it is requested. This is exactly what the plugin I mentioned and my code does. Send POST and requesting URL of published post at the same time doesnt work. I send a GET request to the address of a newly created WordPress post. WHAT DOES NOT WORK is caching this WordPress post The plugin I mentioned works with other Full Page Cache systems that work the same way as LiteSpeed. That is, the first visits to the page cache it. For some reason this doesnt work with LSCache when the request doesnt come from a real browser. The problem is not with these plugins, but with LSCache. I suppose there is some header missing in the request. The plugin I mentioned works with other Full Page Cache systems that work the same way as LiteSpeed. No, LScache is a webserver based HTTP cache. All others use PHP. If the other plugin doesnt work with LScache the reason for it can be that this plugin doesnt send a real HTTP request like http://wwww.domain.com. You can verify it if you check access_log. If there are no entries coming from this plugin/your server, then this is the confirmation for it. No, LScache is a webserver based HTTP cache. All others use PHP. My point was that caching of the page is triggered in the same way. By the first visit. And yes, I verified the request and all the time I am trying to tell you that it works and is correct. The problem is that LSCache does not cache such request. The problem is that LSCache does not cache such request. The most plausible reason can only be that requests from this plugin are not real and not complete HTTP requests. LScache has no special requirements for it, but always must be a complete URL like http(s)://(www.)domain.com/whatever(.php) and it doesnt matter where this request come from, internal or external or whatever device/software is used. You finally understood what I described in the topic Thats why I ask what could be missing in the request. See the code I provided at the beginning. If you are not a developer, then lets wait for someone more technically knowledgeable in LiteSpeed like @CacheCrawler. You finally understood what I described in the topic Yes and already since in your topic post. I develop plugins for LScache and LiteSpeed since many years, but dont know code of WP, so you should wait for plugin support. Maybe he has any idea. Hi, actually I dont have any idea for instance. the request code looks alright to me but here are something you can try/check/test: 1. did you enable guest mode ? if so , your request will hit guest page instead of normal page , so if you check normal page with browser that is not first access, you will see it MISS 2. can try mimic full chrome header , instead of only send accept and UA 3. plugins debug log and server debug log will always be very helpful to give information what exactly has occured 4. have you checked the crawler source code ? https://github.com/litespeedtech/lscache_wp/blob/master/src/crawler.cls.php best regards, From what I understand (from servers debug log), when we publish a post or when we update an existing post, the request from our code (via add_action) gets executed at first. Only then, LSWS flushes the cache. Let me dig further, by looking into the response headers (of the request that tries to preload the post). that makes sense maybe you can use this https://docs.litespeedtech.com/lscache/lscwp/api/#hook-action-for-post-purges
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference