0

I have a domain that hosts a react website in an s3 bucket via cloudfront. There is also a wordpress site hosted on a subdomain of that domain, and in the cloudfront distribution for the web app, I have two behaviors set up with path patterns en and en/* that are set up with the wordpress subdomain as its origin.

This setup seems to work when visiting en/* paths in incognito mode, and in browsers that have never visited the main domain. However, in a browser that has visited the domain before, the browser renders the react app instead of the wordpress page. Doing an empty cache and hard reload causes it to display the wordpress page, but another refresh after that and it's back to rendering the web app. This happens very consistently.

When the react app is rendered at a url that should render the wordpress app, I get the following response header: x-cache: RefreshHit from cloudfront

Also, while a browser that has never visited the react app will correctly load the wordpress app when visiting a path starting with /en, once that browser has visited the react app, paths starting with /en no longer render the wordpress app

What exactly is going on here? And is there a way to get it to render the wordpress app consistently without users having to completely clear their browser's cache? Is there a way to clear the relevant cache item using javascript so that I can do so from within the react app when it detects it is on one of those paths?

Katie
  • 103
  • 3

1 Answers1

0

The problem turned out to be unrelated to my cloudfront or s3 configuration, and was instead due to the service worker launched by the react app intercepting all requests to the domain once it was launched. Removing the service worker (which I was able to do as it is no longer needed) resolved the issue.

Katie
  • 103
  • 3