CloudFront with Edge Side Includes?

3.1k Views Asked by At

I've only recently been reading up on the capabilities of Varnish Cache to help optimize my PHP website's performance. I read about a feature called Edge Side Includes, which seems to give me the option to build widgets of html content that can be cached on a component level. So that a single page of dynamic content can have parts of the page cached, and other parts not cached.

I then started to look into Amazon CloudFront, which seems to offer page level caching abilities as well. But it isn't clear to me if CloudFront offers the equivalent of Edge Side Includes. Can someone clarify for me if that is possible? This would influence the way I architect my PHP website.

1

There are 1 best solutions below

2
On

Unfortunately Cloudfront does not support ESI at this date.

You have three options moving forward.

  1. Don't cache content this content in Cloudfront

  2. Cache but with a low TTL. E.g. cache pages in Cloudfront with a TTL of only 1-20min depending on your application needs.

  3. Implement a backgrund job that invalidates the Cloudfront cache when something is changed. Beware that Cloudfront have a few limitations on how many concurrent invalidation jobs that can run at the same time. I.e. if your content changes often this might not work. Read more about these limits here.

Update You might be able to achieve ESI functionality with Cloudflare and the use of their "Workers" Cloudflare Workers and ESI