-
Notifications
You must be signed in to change notification settings - Fork 182
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
Nginx / Lua based approach to Open Graph tags #422
base: master
Are you sure you want to change the base?
Conversation
A tangentially related idea that I had while writing this, since the lua is embedded within Nginx it's possible to return the correct logical HTTP status codes for resources which might not exist. e.g. making an initial request to |
Can't we just add a route to our existing REST application that will generate these stub HTML files instead? It wouldn't require adding a dependency to Lua and it would be more lightweight. |
@sgsunder absolutely possible, I just didn't take that approach because it involved the backend containing some of the code from the frontend I can try that approach, just need to address the following points:
Then I think I could try that approach and compare. Right now before I even have a plan I think it'll turn into a [faster response and larger frontend container] vs [slim frontend and slightly higher response times]. Another point to research is whether the output from the python API can be sent chunked, so that the browser can start loading the SPA assets before all the page tag information has been fetched by the server. (You can see where I do this in the lua by flushing the output.) |
@robobenklein I made PR #441 trying this out, I'm open to any feedback and we can discuss which implementation would be more efficient. |
This is an alternative option for #416 which I believe has the following benefits compared to #421
There are some issues with this implementation which I want to fix first though:
/api/info
)NOTE: this is still a work in progress (draft PR)
Things still TODO:
Can all the page to API requests be done simply by addingNo, some page links might include information afterwards, like/api
to the front of them? (/post/1
->/api/post/1
and/tag/name
->/api/tag/name
)/post/1/query=cooltag
If so, should we depend on this in the future? (I think it would reduce maintenance effort later on if it does change, but I doubt it would.)Regex/patterns to match paths is probably the best move to not place requirements on the paths the frontend app usesCan we avoid an extra API call by checking to see if the access level is non-Yes, done.anonymous
before making the request to an authenticated endpoint?We should send the first part of the html response before starting the API requests in order to let the browser start preloadingDone.Need to handle the case when the backend is offline or unresponsiveDoneexternal_host_url
orrequest_uri_path
to prevent XSS?