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

Fix ETL staging server MDim caching issues #4296

Merged
merged 2 commits into from
Dec 13, 2024
Merged

Conversation

danyx23
Copy link
Contributor

@danyx23 danyx23 commented Dec 12, 2024

This PR fixes an issue in the MDim workflow when working in the ETL with staging servers. This is the setup that a lot of data managers use.

Lucas reported that when he makes changes in the ETL on his machine and runs the ETL update targeting a staging server, MDim views would not get updated.

It turns out that the reason this happens (and is different from the local workflow) is that on staging servers, /grapher/by-uuid/UUID.config.json is not handled by the mock site router but instead by CF functions (atm wrangler if I understand correctly, soon probably the CF preview deploy).

These CF functions have s-MaxAge set and so cache the results for a good while.

This PR enables the IsPreviewing flag that we use in the runSiteFooterScripts script and if it is set then reqeusts to the above url append ?nocache which then leads to the CF function (either wrangler or preview deploy) to request the freshest version from R2.

While I was at it I also reduced the cache times. These small json objects don't have to be cached for a full hour, 5 min should be plenty for prod.

@owidbot
Copy link
Contributor

owidbot commented Dec 12, 2024

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-shorten-config-cache-times

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2024-12-12 18:00:41 UTC
Execution time: 1.21 seconds

@@ -242,7 +248,7 @@ export const MultiDimDataPageContent = ({

const currentView = useView(currentSettings, config)
const { varDatapageData, varGrapherConfig, grapherConfigIsReady } =
useVarDatapageData(config, currentView)
useVarDatapageData(config, currentView, isPreviewing ?? false)
Copy link
Member

Choose a reason for hiding this comment

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

could also just set a default in the parameter destructuring 🙂

Copy link
Contributor

@rakyi rakyi left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

Since we are already introducing a change in behavior between prod and staging (for a good reason) would it make sense to use the environment we run in to decide on what to do? So instead of passing the flag around, we could disable caching in staging for all requests to this endpoint.

Copy link
Contributor Author

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

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

@rakyi yes I thought of this as well - but it can also be useful to have a test environment behave very similar to the prod setup including caching - so that when you make non-admin requests you can test if the caching is what you expect. Let's chat about it in the dev call next week - for now I'd leave it as is.

@danyx23 danyx23 merged commit 28ba2e4 into master Dec 13, 2024
25 checks passed
@danyx23 danyx23 deleted the shorten-config-cache-times branch December 13, 2024 14:34
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.

4 participants