Use middleware for grapher redirects #4563
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This has been now reported in Slack multiple times. It confuses authors that they don't see the change after they create a chart redirect. It also means different users can see different charts when clicking on the same link, depending on whether the CDN datacenter that handles their request had the old page cached. I tested this case with Pablo A.
I naively measured how much it takes to fetch a redirect slug in Cloudflare preview deployment, and it's between 2–10 ms for the majority of requests, and the highest outlier I saw was 35 ms.
If there is no redirect, we pay this cost once, if there is one, we pay it twice — first the page gets redirected successfully, then we check the second time as we handle the now correct request.
TODO: It might be better to take the same approach as we did for deleted articles and add temporary redirects to the redirects table with a TTL that is cleaned up in a cron job.