Title: Avoiding caching ActivityPub content
Last modified: April 30, 2025

---

# Avoiding caching ActivityPub content

 *  Resolved [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/)
 * When using LS Cache with [ActivityPub](https://wordpress.org/plugins/activitypub/),
   sometimes the JSON content from ActivityPub gets cached instead of the actual
   page. Both versions are served from the same URL, but the ActivityPub request
   comes with an `Accept: application/activity+json` header.
 * Is there a way to prevent LS Cache from caching the JSON output, or to have a
   different cache for those requests?

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/page/2/?output_format=md)

 *  Plugin Support [litetim](https://wordpress.org/support/users/litetim/)
 * (@litetim)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18444089)
 * [@msaari](https://wordpress.org/support/users/msaari/) 
   Try using this setting:
   [https://docs.litespeedtech.com/lscache/lscwp/cache/#do-not-cache-uris](https://docs.litespeedtech.com/lscache/lscwp/cache/#do-not-cache-uris)
   Another setting you can look into is: [https://docs.litespeedtech.com/lscache/lscwp/cache/#cache-rest-api](https://docs.litespeedtech.com/lscache/lscwp/cache/#cache-rest-api)
 *  Thread Starter [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18444467)
 * “Do not cache URIs” doesn’t help. The URI is the same. The only difference is
   the “Accept” header.
 * “Cache REST API” doesn’t help either; these are not REST API calls. These are
   plain front end calls, just with a different “Accept” header.
 * Ideally, LS Cache would respect the “Accept” header and would cache both the 
   HTML and JSON content separately, or at least not serve HTML from the cache when
   the “Accept” header requests JSON.
 * For example, you can see how WP Super Cache includes the “Accept” header in the
   cache tag if it’s not “text/html”: [https://github.com/Automattic/wp-super-cache/blob/004a3c3a21363578f25976dfdbe6a8dd40ae0f96/wp-cache-phase2.php#L34](https://github.com/Automattic/wp-super-cache/blob/004a3c3a21363578f25976dfdbe6a8dd40ae0f96/wp-cache-phase2.php#L34)
   This way the cache won’t return the wrong content type.
 *  Plugin Support [litetim](https://wordpress.org/support/users/litetim/)
 * (@litetim)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18444561)
 * [@msaari](https://wordpress.org/support/users/msaari/) 
   Please send a report 
   from LSC => Toolbox => Report => click on “Send to litespeed” then share the 
   ID with me
 *  Thread Starter [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18444570)
 * BYUAVDFL. I’m using the [ActivityPub](https://wordpress.org/plugins/activitypub/)
   plugin.
 * For example, [https://www.lautapeliopas.fi/artikkelit/kymmenen-vuotta-sitten-2015/](https://www.lautapeliopas.fi/artikkelit/kymmenen-vuotta-sitten-2015/)
   returns the HTML page and [https://www.lautapeliopas.fi/?p=43695](https://www.lautapeliopas.fi/?p=43695)
   with the “Accept: application/activity+json” header returns the ActivityPub JSON
   page (without the header, it returns the HTML page). This works, and right now
   when I test this, both pages show a “hit” from LS Cache.
 * However, occasionally the ActivityPub JSON gets cached so that visitors to [https://www.lautapeliopas.fi/artikkelit/kymmenen-vuotta-sitten-2015/](https://www.lautapeliopas.fi/artikkelit/kymmenen-vuotta-sitten-2015/)
   see only the ActivityPub JSON. This happens rarely, but this specific page was
   released a couple of days ago and I already got two reports from users who got
   the JSON instead of the HTML.
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18445127)
 *     ```wp-block-code
       RewriteCond %{HTTP:Accept} applicationRewriteRule ^ - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+isjson]
       ```
   
 * okay , what you are looking for is more like a cache vary
 * please try add this at top of your .htaccess
 *  [Matthias Pfefferle](https://wordpress.org/support/users/pfefferle/)
 * (@pfefferle)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18445471)
 * If lightspeed cache does support the vary header you can go to the ActivityPub
   advanced settings and enable that!
 *  Thread Starter [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18445648)
 * Nice! Those are some well-hidden advanced settings 😉 It would be nice to have
   some note that these advanced settings exist… If I enable that setting, are the.
   htaccess modifications necessary?
 *  [Matthias Pfefferle](https://wordpress.org/support/users/pfefferle/)
 * (@pfefferle)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18445658)
 * [@msaari](https://wordpress.org/support/users/msaari/) it is on purpose that 
   there is no documentation about it ☺️
 * it is too easy to break things with these settings!
 *  Thread Starter [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18446041)
 * [@pfefferle](https://wordpress.org/support/users/pfefferle/) Maybe add a check
   for some of the most-used cache plugins and show a warning? “Hi, I see you’re
   using a cache plugin, check this setting to avoid problems with the cache”?
 *  [Matthias Pfefferle](https://wordpress.org/support/users/pfefferle/)
 * (@pfefferle)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18446427)
 * [@msaari](https://wordpress.org/support/users/msaari/) if you can verify that
   the setting fixes your issue, I will change the default behaviour of the `vary`
   header setting when `LiteSpeed Cache` is active.
 *  Thread Starter [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18446653)
 * Unfortunately, this is something I can’t solidly verify – this is something that
   happens occasionally, and most of the time I don’t even hear of it. If I hear
   no complaints within a year, it’s probably fine…
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18446712)
 * hi [@pfefferle](https://wordpress.org/support/users/pfefferle/) , you may need
   to explicitily insert the rules I mentioned at top of htaccess, in order to tell
   cache engine to vary header , and it’s on the condition with `accept` header ,
   not by the `vary` header though.
 *     ```wp-block-code
       <IfModule LiteSeed>RewriteCond %{HTTP:Accept} applicationRewriteRule ^ - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+isjson]</IfModule>
       ```
   
 * better to enclose it with ifmodule , and also only insert it if LSCWP is enabled,
   you can check it by `if (defined('LSCWP_V'))`
    -  This reply was modified 1 year, 1 month ago by [qtwrk](https://wordpress.org/support/users/qtwrk/).
 *  Thread Starter [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18457576)
 * [@pfefferle](https://wordpress.org/support/users/pfefferle/) I can now confirm
   that the Vary header setting alone does not solve the problem.
 *  [Matthias Pfefferle](https://wordpress.org/support/users/pfefferle/)
 * (@pfefferle)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18457785)
 * Thanks for the feedback [@msaari](https://wordpress.org/support/users/msaari/)!
   With the next version, we provide an option to disable Content-Negotiation for
   user facing sites. This might be another option, to prevent JSON in the cache.
 *  [Matthias Pfefferle](https://wordpress.org/support/users/pfefferle/)
 * (@pfefferle)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/#post-18457789)
 * I will also work on an integration for the LiteSpeed Cache Plugin, like we currently
   did for Surge: [https://github.com/Automattic/wordpress-activitypub/pull/1648](https://github.com/Automattic/wordpress-activitypub/pull/1648)
 * Maybe we can automatically add the .htaccess rules if both plugins are installed.
   I will drop an update here, maybe you can have a look then [@qtwrk](https://wordpress.org/support/users/qtwrk/)

Viewing 15 replies - 1 through 15 (of 22 total)

1 [2](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/page/2/?output_format=md)

The topic ‘Avoiding caching ActivityPub content’ 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/)

 * 22 replies
 * 4 participants
 * Last reply from: [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * Last activity: [1 year, 1 month ago](https://wordpress.org/support/topic/avoiding-caching-activitypub-content/page/2/#post-18465312)
 * Status: resolved