Score:0

Cloudfront distribution with react app and wordpress app hosted on same domain - how to get browsers with react app cached to render wordpress app?

in flag

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?

Score:0
in flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.