Skip to content

Proxito: canonical redirects don't need further inspection of the version/project/filename #10065

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

Closed
stsewd opened this issue Feb 22, 2023 · 3 comments · Fixed by #10069
Closed

Comments

@stsewd
Copy link
Member

stsewd commented Feb 22, 2023

Currently, our canonical redirect logic expects to the current project/version/filename

return self.canonical_redirect(
request=request,
final_project=final_project,
version_slug=version_slug,
filename=filename,
redirect_type=redirect_type,
is_external_version=is_external,
)

But in reality, we shouldn't need those, because:

  • http to https redirects don't need any of that information, we just need to change the protocol!
  • subproject redirects only need the project from the unresolved domain, and resolve that as main-project.rtd.io/projects/subproject/{path} (no need for version or filename!)
  • canonical domain redirects don't need any of that information, we just need to change the domain! And for subprojects, we don't allow custom domains on subprojects, and they will be picked up in the previous redirect, so nothing to worry about.

Moving the execution of the http-https and to-canonical-domain redirects should be easy, moving the other one requires adding a new way of unresolving a project

def resolve(
self, project, require_https=False, filename='', query_params='',
external=None, **kwargs
):

this new way will just accept the project and return the root path of it, no versions, no translations, just the root (like it would be a single version), for example:

  • project.rtd.io/
  • docs.example.com/
  • project.rtd.io/projects/subproject/
  • docs.example.com/projects/subproject/
@stsewd stsewd mentioned this issue Feb 23, 2023
@github-project-automation github-project-automation bot moved this to Planned in 📍Roadmap Feb 23, 2023
stsewd added a commit that referenced this issue Feb 24, 2023
stsewd added a commit that referenced this issue Feb 27, 2023
stsewd added a commit that referenced this issue Feb 27, 2023
@ericholscher
Copy link
Member

@stsewd I think the trade off here is that we end up with multiple requests, instead of a single request. I believe the original implementation was trying to get the user to the right place with 1 HTTP redirect. That said, if we can be smarter here with caching, it would be great, but multiple round trips to the server is also a huge source of slowness for users, and something to consider in design.

@humitos
Copy link
Member

humitos commented Feb 28, 2023

but multiple round trips to the server is also a huge source of slowness for users, and something to consider in design.

I think 1 HTTP redirect will be harder to implement correctly. Also, once implemented, I suppose the code will be harder to follow as well 😄

@ericholscher
Copy link
Member

but multiple round trips to the server is also a huge source of slowness for users, and something to consider in design.

I think 1 HTTP redirect will be harder to implement correctly. Also, once implemented, I suppose the code will be harder to follow as well 😄

Yea... looking at the implementation, I really like the simplicity of it, so I think it's likely the correct approach. Just wanting to make sure we're considering the UX when we design it :)

@github-project-automation github-project-automation bot moved this from Planned to Done in 📍Roadmap Mar 1, 2023
stsewd added a commit that referenced this issue Mar 1, 2023
Implementing the plan from #10065.

- I'm caching all the redirects by default now, since the final URL will be checked for authz
- Cache tags now are given by the project from the unresolved domain, since we are caching the response on that domain! Previous behavior wasn't correct.

Closes #10065
stsewd added a commit that referenced this issue Mar 2, 2023
This is an initial usage of the new proxito implementation to serve files. It's under a feature flag, so it can be enabled per-project.

- We still need to adapt our 404 handler to make use of this new implementation (it could be simplified with #10061)
- We are still using our re paths to match the URLs, but we don't make use of the captured parameters, we use the unresolver for that. This also means that things like #2292 won't be solved till we do the whole migration.
-  There is a lot of repetition from the original get method, but some of it could be simplified with #10065.

Tests will pass once we have merged one private PR that we have pending.

> **Note**
> We don't support custom urlconfs yet, so we shouldn't enable it for those projects yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants