Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update rest api no-cache example code #9160

Merged
merged 1 commit into from
Aug 9, 2024
Merged

Conversation

jazzsequence
Copy link
Contributor

Fixes #8675

Summary

Bypassing Cache with HTTP Headers - Updates the code snippet example for bypassing cache headers for rest requests

@jazzsequence jazzsequence requested a review from a team as a code owner August 8, 2024 16:47
Copy link

⚡ Deployed with Pantheon Decoupled

This build was successfully deployed with Pantheon. You can track the build logs here.

👀 Preview: https://pr-9160-documentation.appa.pantheon.site
🛠️ Manage in Pantheon: https://dashboard.pantheon.io/site/2b30153f-e8b1-4427-b076-6109e704ba5d/overview

Copy link
Contributor

@stevector stevector left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jazzsequence did you try this code on a site on the platform? If so, I'll approve/merge.

@jazzsequence
Copy link
Contributor Author

@stevector I haven't yet. I want to do that before we merge.

@jazzsequence
Copy link
Contributor Author

jazzsequence commented Aug 9, 2024

@stevector
So, I think the approach is correct -- in that we should not semantically be performing an action inside something intended to filter content -- however, the solution does not work. I think this is actually related to this issue (related community slack conversation). The underlying issue being it doesn't matter if the application sends no-cache headers to the CDN, the CDN does not change its behavior when it receives those headers and continues to serve cached copies.

Additionally, implementing the suggested change causes 502 errors if a REST API endpoint does not have a cached copy yet. For example, if I go to /wp-json/wp/v2/pages/ on a site where I haven't already hit that endpoint, I get a 502. However, if I remove the code and visit that endpoint and then re-enable it, I will always get the cached version of that endpoint (until the cache expires). I think the actual solution here is to remove this recommendation until the underlying issue is resolved (and open a docs issue that we come back to this if/when that issue is resolved). It's currently sitting inside a feature request (FEAT-1420).

@jazzsequence
Copy link
Contributor Author

lol it would help if I used the right header name (Cache-Control not Cache Control) in my test code 🙃
Nevermind everything, this is good 😂

@jazzsequence jazzsequence merged commit b7c9825 into main Aug 9, 2024
9 checks passed
@jazzsequence jazzsequence deleted the 8675-fix-wp-filter-example branch August 9, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bypassing Cache with HTTP Headers Doc Update
2 participants