pluginkollektiv / cachify

Smart but efficient cache solution for WordPress. Use DB, HDD, APC or Memcached for storing your blog pages. Make WordPress faster!
https://wordpress.org/plugins/cachify/
GNU General Public License v2.0
101 stars 32 forks source link

Cachify does not support Content Negotiation #265

Closed pfefferle closed 1 year ago

pfefferle commented 2 years ago

Describe the bug If a page has different views based on the Accept header, Cachify caches the output of the first request. If the request is application/json for example, Cachify always returns the JSON output on every following request.

To Reproduce Steps to reproduce the behavior:

  1. Install the ActivityPub plugin
  2. Load the author page with Accept header application/activity+json
  3. Load the author page again in the browser
  4. See the JSON output

Expected behavior Only cache requests with html Accept headers (https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation/List_of_default_Accept_values) and return the dynamic/uncached content otherwise.

florianbrinkmann commented 2 years ago

Maybe we can add a check in the .htaccess like that:

<If "(%{HTTP_ACCEPT} -strmatch '*text/html*')">
    Rewrite 
</If>

Tried to test that quickly but had a setup issue with cachify :D Wanted to post that here so I do not forget that.