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

Avoid an extra network round trip when proxying PDFs #481

Open
seanh opened this issue May 5, 2021 · 0 comments
Open

Avoid an extra network round trip when proxying PDFs #481

seanh opened this issue May 5, 2021 · 0 comments

Comments

@seanh
Copy link
Contributor

seanh commented May 5, 2021

When a URL like https://via.hypothes.is/https://example.com/foo.pdf calls the proxy() view, the view:

  1. Determines whether https://example.com/foo.pdf is HTML or PDF (by making a GET request to https://example.com/foo.pdf and looking at the Content-Type)
  2. Renders an <iframe> whose src is either https://via.hypothes.is/pdf?url=https://example.com/foo.pdf (which goes to the view_pdf() view) or https://viahtml.hypothes.is/proxy/https://example.com/foo.pdf depending on whether https://example.com/foo.pdf is a PDF or not

This causes the browser to make an extra network round trip to get the <iframe>'s src URL.

In the case of PDFs this extra network round trip could be avoided: the proxy() view could just return the PDF.js response (as would be returned by the view_pdf() view) directly.

In the case of HTML the proxy() view does still need to return an <iframe> since HTML is handled by a separate app.

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

No branches or pull requests

1 participant