Edge Side Includes?


(Ryan Erwin) #1

The folks at Fastly said that to make the most of the Site Shield for Discourse, they recommended using Edge Site Includes…

Would it basically be a full rewrite to try and get ESI integrated with Fastly?
Or are there a relatively small number of areas that would need to change?

We have a site that gets significant traffic spikes (~500k users), so a solution like ESI sounds like it would be an efficient way to survive during those spikes…


(Michael Howell) #2

Edge-side includes allow a web app to serve up less data and have the CDN stitch in boilerplate. For example, a forum might serve something like this up, and then the edge replaces the include directives with HTML that may or may not already be in the cache:

<? include "head.html.inc" ?>
<section class="post"><? include "user/ryanerwin/posthead.html.inc" ?>
<p>The folks at Fastly said that to make the most of the Site Shield for Discourse, they recommended using Edge Site Includes…</p><p>Would it basically be a full rewrite to try and get ESI integrated with Fastly?</p><p>We have a site that gets significant traffic spikes (~500k users), so a solution like ESI sounds like it would be an efficient way to survive during those spikes…</p>
<? include "postfooterbuttons.html.inc" ?>
</section>
<? include "footer.html.inc" ?>

As a “Single-Page Application”, Discourse really doesn’t serve very many web pages. It mostly serves JSON responses like this. Notice how there isn’t very much boilerplate in the JSON document; how the headers and buttons aren’t in this JSON document; just actual data.

What SPAs do is almost the same thing as edge-side includes, except that instead of the “edge” being at the CDN, they do it even “edgier”; the inclusions are done in the browser itself.


(Kane York) #3

I’d be extremely careful with this - users are free to place ESI directives in their posts.


(Michael Howell) #4

I realize that I didn’t make it clear in my post:

Don’t use Edge-Side Includes with Discourse. There’s no point; the way the app is built it wouldn’t really benefit from having them.