wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Compatibility with ActivityPub plugin Accept header

Open suzoutlet opened this issue 7 months ago • 1 comments

Describe the bug The issue is that ActivityPub has a different output for the same page depending on the value of the Accept header.

What happens here is that once we cache the page, we keep on sending the same cache even if the Accept header is not the same. And our REST API cache mechanism deals only with /wp-json/ URLs.

To Reproduce Steps to reproduce the behavior:

  • Install the ActivityPub plugin
  • Visit a post in the Browser (so that the post will be cached)
  • Visit the post with Accept header application/activity+json > it returns HTML output > wrong output
  • Then deactivate WP Rocket
  • Visit the post with Accept header application/activity+json > JSON output > correct output

Expected behavior To make this compatible, we’d need to be able to detect the Accept header and generate a different cache based on that. So, if the requester sends Accept: application/activity+json we should deliver a different page. Alternatively, we could bypass the cache when application/activity+json is calling one of their REST endpoints.

Additional context

suzoutlet avatar May 14 '25 14:05 suzoutlet

Related: https://github.com/wp-media/wp-rocket/issues/2528

webtrainingwheels avatar May 14 '25 15:05 webtrainingwheels