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

Issue with Pantheon Page Caching #311

Open
drosal2025 opened this issue Jan 17, 2025 · 0 comments
Open

Issue with Pantheon Page Caching #311

drosal2025 opened this issue Jan 17, 2025 · 0 comments

Comments

@drosal2025
Copy link

Hello, on our product page, I have been experiencing issues on mobile. Anytime a state is selected within the filters, it fails to update properly until I clear the cache.

I have been working with Pantheon Support to fix this issue, but the code snippets they provided did not fix the issue (trying to just avoid caching on that particular page on mobile). They mentioned that the root cause of this issue stemmed from the following:

That page makes a request to admin-ajax.php with a WordPress nonce.

The request looks like:

https://spartansurfaces.com/wp-admin/admin-ajax.php?regions%5B%5D=arizona&mg_nonce=402d7ba92f&action=mg_filter_team

By default WordPress has those valid for 24 hours, and it looks like it comes from the page data:

<script type="text/javascript" id="theme-scripts-js-extra"> /* <![CDATA[ */ var urls = {"base":"https:\/\/spartansurfaces.com","theme":"https:\/\/spartansurfaces.com\/wp-content\/themes\/spartan-surfaces","ajax":"https:\/\/spartansurfaces.com\/wp-admin\/admin-ajax.php"}; var vars = {"nonce":"402d7ba92f"}; var info = []; /* ]]> */ </script>
And the page data there is cached for 7 days on the edge, so that nonce will become invalid. It's possible you're noticing this now as a month or two ago WordPress was updated to default to 7 days instead of the previous 10 minutes I believe.

There are a few options they mentioned to try and resolve:

  1. Extend the nonce lifetime
  2. Reduce that page's caching time
  3. Utilize a different endpoint without a nonce

My first question is, if this was a recent wordpress update, is there any areas where we can adjust the pantheon caching plugin to account for this?

And if not, can someone assist me in trying options 1 or 3?

Code we tried:

if (is_page(4293) && wp_is_mobile()) { header('Cache-Control: no-cache, no-store, must-revalidate'); }

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

No branches or pull requests

1 participant