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

Use Surrogate-Key headers for docs.python.org #510

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions salt/docs/config/nginx.docs-redirects.conf
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ location ~ ^/((2|3)(\.[0-9]+)?|dev)/\w+/[\d\w\.]+(?!\.html)$ {
if (-f "${request_filename}.html") {
return 301 https://$host:$request_uri.html;
}
add_header Surrogate-Key en/$1 always;
}

# Add the Surrogate-Key for bulk CDN purging
# xref https://docs.fastly.com/en/guides/working-with-surrogate-keys
location ~ ^/((2|3)(\.[0-9]+)?|dev)/ {
add_header Surrogate-Key en/$1 always;
}
location ~ ^/(es|fr|id|it|ja|ko|pl|pt-br|tr|uk|zh-cn|zh-tw)/((2|3)(\.[0-9]+)?|dev)/ {
add_header Surrogate-Key $1/$2 always;
Comment on lines +191 to +197
Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally I had hoped to use some sort of non-binding match construct to add the headers, but it seems that NGINX location directives will always bind. The end goal is simply to add some unique prefix for every second level path (and English) that we can use to purge. I think the approach here is fine given every other rule here is a redirect, but worth pointing out.

Fastly has some text about adding surrogate keys via vcl_fetch, but I don't know where I'd configure that.

A

Copy link
Member

Choose a reason for hiding this comment

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

This could be configured in our Fastly service for docs.python.org, but is probably more scrutable (and testable, nice!) here.

}

# Map old, 2.5-and-earlier directory names to 2.6-and-later names.
Expand Down
Loading
Loading