Title: REST API / PURGE TAG
Last modified: May 24, 2025

---

# REST API / PURGE TAG

 *  Resolved [nookyyy](https://wordpress.org/support/users/nookyyy/)
 * (@nookyyy)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/)
 * Hi i got a question regarding caching / purging of rest api calls
 * I would like to cache the rest api, and be able to purge a tag / url. I’ve implemented
   everything and tried both but when the purge is executed the whole rest api endpoint
   is getting purged aswell. I would like to specificly target a tag or an url and
   not purge the whole rest api.
 * It does work, when i turn off “purge rest api” in the cache tab and manually 
   add the endpoint /custom-api/v1/ for example, so my code should be fine?
 * is this a bug or how can i make sure that only the tag / url i want to purge 
   gets purged while keeping the cache of the rest api ?
 * regards

Viewing 10 replies - 16 through 25 (of 25 total)

[←](https://wordpress.org/support/topic/rest-api-purge-tag/?output_format=md) [1](https://wordpress.org/support/topic/rest-api-purge-tag/?output_format=md)
2

 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18485716)
 * the POST cache also checks against request body as well , if body changes , it
   will be miss
 *  Thread Starter [nookyyy](https://wordpress.org/support/users/nookyyy/)
 * (@nookyyy)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18485866)
 * Ok how can i narrow down the reason i always get a miss despite the same req 
   body + uri – i dont see any difference on that first filter load
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18485906)
 * well , that’s good question , after re-think about the issue , I am not sure 
   if plugin was able to handle such request caching
 * it has feature to cache POST, it was designed to cache `admin-ajax.php` POST 
   request, but not sure if it works for other URIs
 * I’d suggest to set up a simple admin-ajax POST to test if cache POST works or
   not first
 * for example
 *     ```wp-block-code
       add_action('wp_ajax_nopriv_get_random_number', 'get_random_number_callback');function get_random_number_callback() {    wp_send_json_success(array('number' => rand(1, 10000)));}
       ```
   
 * then go to cache -> advanced -> ajax cache TTL , put `get_random_number 3600`
 * then curl it like `curl -i -X POST -d "action=get_random_number" https://your_domain.
   com/wp-admin/admin-ajax.php` , see if you can get cache hit there first
    -  This reply was modified 10 months, 2 weeks ago by [qtwrk](https://wordpress.org/support/users/qtwrk/).
 *  Thread Starter [nookyyy](https://wordpress.org/support/users/nookyyy/)
 * (@nookyyy)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18485917)
 * i think i found out how to do it – found this in another forum:
 * `CachePost on
   RewriteCond %{REQUEST_URI} ^/wp-json/wpgb/v2/filter/ [NC]RewriteRule.*-[
   E=cache-control:no-vary]
 * I had to add those 2 lines aswell – now i get a hit – need to check if it works
   for different actions / post bodys – will update
 *  Thread Starter [nookyyy](https://wordpress.org/support/users/nookyyy/)
 * (@nookyyy)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18486045)
 * ok seems to work so it needs both to work correctly: cache settings in wp plugin
   + htaccess rule / Apache configuration
   i guess it would be nice if the official
   doc gets updated with these information 😉Then on to the last “problem”: why 
   is my custom rest endpoint not getting cached when i activate cache rest (without
   the cache uri) / why is full rest endpoint getting purged even though i have 
   all the settings turned off
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18486053)
 * wasn’t that a POST request to your REST ? that by default won’t , only admin-
   ajax.php action configured through that cache -> advanced -> admin-ajax cache
   will be cached by plugin.
 * for purge , you got full log on that ?
 *  Thread Starter [nookyyy](https://wordpress.org/support/users/nookyyy/)
 * (@nookyyy)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18486169)
 * No my custom endpoint /reviewAPI/v1/ is GET only
 * the purge log when i update a post is here: [https://pastebin.ubuntu.com/p/RSZMf8zfh3/](https://pastebin.ubuntu.com/p/RSZMf8zfh3/)(
   my custom tag gets added via my function ( and the goal was to purge posts + 
   rest uris depending on what the post changes for other posts )
   and because of
   the b79_REST TAG the whole REST gets purged. My fix right now is to remove that
   tag in the header, when one of my custom tag is present.
 * Same happens when i delete a post for example:
 * `05/27/25 17:01:22.815 [87.145.134.193:64444 1 eKS] 💓 ------GET HTTP/1.1 (HTTPS)/
   wp-admin/post.php
   05/27/25 17:01:22.815 [87.145.134.193:64444 1 eKS] Query String:
   post=11188&action=trash&_wpnonce=d2ebb33bcd05/27/25 17:01:22.815 [87.145.134.193:
   64444 1 eKS] HTTP_REFERER: https://nookyyy.com/wp-admin/edit.php?post_type=revie...
   05/27/25 17:01:22.815 [87.145.134.193:64444 1 eKS] User Agent: Mozilla/5.0 (Windows
   NT 10.0; Win64; x64) AppleWebKit...05/27/25 17:01:22.815 [87.145.134.193:64444
   1 eKS] Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,
   image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.705/27/25
   17:01:22.815 [87.145.134.193:64444 1 eKS] Accept Encoding: gzip, deflate, br,
   zstd05/27/25 17:01:22.815 [87.145.134.193:64444 1 eKS] Cookie _lscache_vary: 
   admin_bar:1;guest_mode:1;logged-in:1;role:9905/27/25 17:01:22.815 [87.145.134.193:
   64444 1 eKS] X-LSCACHE: true05/27/25 17:01:22.815 [87.145.134.193:64444 1 eKS]
   LSCACHE_VARY_VALUE: +webp05/27/25 17:01:22.815 [87.145.134.193:64444 1 eKS] X-
   LiteSpeed-Purge: public,stale,b79_Po.11188,b79_W.recent-posts-1,b79_FD,b79_REST
   => LiteSpeed\LSC->send_headers()@603 => WP_Hook->apply_filters(,ARRAY)@324 =>
   WP_Hook->do_action(ARRAY)@348 =>/var/www/vhosts/nookyyy.com/httpdocs/wp-includes/
   load.php@517
    -  This reply was modified 10 months, 2 weeks ago by [nookyyy](https://wordpress.org/support/users/nookyyy/).
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18486173)
 * [https://github.com/litespeedtech/lscache_wp/blob/3c68cfb1d478fb6eb9f0c85dadc098da1a63e19a/src/purge.cls.php#L907](https://github.com/litespeedtech/lscache_wp/blob/3c68cfb1d478fb6eb9f0c85dadc098da1a63e19a/src/purge.cls.php#L907)
 * looks like it was hard-coded to purge rest alone with it
 *  Thread Starter [nookyyy](https://wordpress.org/support/users/nookyyy/)
 * (@nookyyy)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18486180)
 * WoW thanks for that info – i guess it would be great to add this info to the 
   docs aswell or maybe even add such an option to the plugin when a user activates
   the cache rest option.
 * Ok but then i know everything i need to know and im able to “work around” those“
   behaviours” – thanks for your help everything seems to work now on my side just
   needs a bit more fine tuning to purge what i want / exclude what i need
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18489439)
 * yeah … I have been chasing after our dev to add a filter to modify the purge 
   header output … it will make everything much easier once it is implemented …

Viewing 10 replies - 16 through 25 (of 25 total)

[←](https://wordpress.org/support/topic/rest-api-purge-tag/?output_format=md) [1](https://wordpress.org/support/topic/rest-api-purge-tag/?output_format=md)
2

The topic ‘REST API / PURGE TAG’ is closed to new replies.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

## Tags

 * [cache](https://wordpress.org/support/topic-tag/cache/)
 * [Purge](https://wordpress.org/support/topic-tag/purge/)

 * 25 replies
 * 2 participants
 * Last reply from: [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * Last activity: [10 months, 2 weeks ago](https://wordpress.org/support/topic/rest-api-purge-tag/page/2/#post-18489439)
 * Status: resolved