darkweak / go-esi Goto Github PK
View Code? Open in Web Editor NEWPure implementation of the non-standard ESI (Edge-Side-Include) specification in Go
License: MIT License
Pure implementation of the non-standard ESI (Edge-Side-Include) specification in Go
License: MIT License
Specification says:
- Protocol Considerations
When an ESI template is processed, a separate request will need to be made for each include encountered. Implementations may use the original request's headers (e.g., Cookie, User-Agent, etc.) when doing so. Additionally, response headers from fragments (e.g., Set-Cookie, Server, Cache-Control, Last-Modified) may be ignored, and should not influence the assembled page.
(emphasis mine)
When creating the child request, some of the headers need to be included for the child response to be constructed properly, for example Cookie
/ Authorization
headers are required to know the identity of the user for which we're constructing the child response.
Some of these headers must NOT be forwarded in cross-origin scenarios. For example, Cookie
and Authorization
musn't be passed unless the child request's host, port and scheme all match. IMO the best approach is to have an allow list of headers in general and a separate list of same-origin headers.
If I'm reading the code correctly, right now all the esi tags are parsed and processed sequentially. This means that if there are 5 esi:includes each taking 50 ms, it'd add up to 250 ms instead of potentially only taking 50 ms if they were all requested at once.
A remedy to this would be to first parse the input, then process all found tags all at once, and only then insert the results in tags' place in the body to be returned.
I notice you're using full URLs in all examples. Symfony ESI will by default generate hostless URLs when generating the ESI include block:
https://symfony.com/doc/current/http_cache/esi.html
Are these supported?
Example:
<esi:include src="/_fragment?signature=..."/>
I use make run-caddy
and access http://localhost:9080 without cookie set.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.