I am using CDn module since 6.x and currently on 7.x. I have used it in maxcdn and amazon cloudfront. I am using it to serve only static content. I wish I could use it to serve dynamic content as well.

There is an old issue #1579902: Support for dynamic content? which discusses this but I have a slightly different implementation and reason in mind.

Cloudfront allows to specify in the header the content should not be cached by CDN (as opposed to invalidate it later using tags).
So CDN module can send all the dynamic html with 0 cache time and CDN will take care of invalidation it. (atleast cloudfront does it).
This is different than the solution described in #1579902: Support for dynamic content?

Why to support this feature ? take advantage of http2 protocol. If your domain is mydomain.com and CDN is say xyz.cloudfront.net. Currently the browser needs to open two separate connections. But with http2 and dynamic content support available in cloudfront, there is only one connection required from browser to CDN and we can achieve significant performance benefits. Since it would like a large distributed reverse proxy for everything (not just for static content).

Would you consider supporting this?

I wonder this is already possible and all we need some recipe to add to .htaccess file like mentioned in README.txt?

Comments

ajayg created an issue. See original summary.

ajayg’s picture

Issue summary: View changes
Wim Leers’s picture

Issue summary: View changes
Related issues: +#1579902: Support for dynamic content?

Added some formatting to the issue summary to make it more legible.

Wim Leers’s picture

Category: Feature request » Support request
Status: Active » Postponed (maintainer needs more info)

I am using CDn module since 6.x and currently on 7.x. I

Wow! That's very cool — how many years have you been using it then? :)

So CDN module can send all the dynamic html with 0 cache time and CDN will take care of invalidation it.

If you do that, the CDN won't actually cache the HTML responses at all — it will just pass them through. There's no need for invalidation then, because the CDN isn't caching these responses. This also means you're incurring latency twice: from origin to the CDN to the client. Instead of just from origin to the client.

Why to support this feature ? take advantage of http2 protocol.

I think you're trying to say that then your own web server doesn't need to deal with HTTP/2 support — the CDN is effectively a proxy providing HTTP/2 support. Is that right? Is that what you mean, and want?

But with http2 and dynamic content support available in cloudfront, there is only one connection required from browser to CDN

HTTP/2 doesn't magically make things faster. Dynamic content support on CloudFront doesn't help very much if it still needs to talk to origin for every single HTML response. Having only a single connection doesn't necessarily make things faster either — if there are dozens of resources to load (dozens of requests), then having multiple connections will actually be faster.

Conclusion: I'm not sure this makes sense.

ajayg’s picture

My site in 21 years old. I was not using CDN module when it was on 5.x but deployed in 6.x. So I guess approx 8 years.

Since Google suggest moving everything to https , I am preparing to add that. And then I realized the next could be http2.
Currently http2 requires TSL , certs and all the overheads that goes with it. I could add the tls support to my origin server but that will require at least two (perhaps more) secure connections. With amazon cloudfront, I could just create one distribution, use free TLS cert on AWS cert manager on cloudfront, map all https to pass through it. Although I know it won't be caching, it still provide multiple other benefits as distributed reverse proxy, WAF(Web app firewall), DDOS protection etc which I don't need to worry. So instead of starting an https connection at my origin and another at cloudfront distribution, it can just start one https connection at the cloudfront , geographically closer to the browser. But this would require the correct expire timestamp set at origin so cloudfront will just pass through.

Basically I am thinking I would need

(Origin server http, I own) + (a reverse proxy+WAF+TLS https, I own) + (CDN https, AWS owns)

anyway for dynamic html passthrough. So why not bundle that with CDN and get benefit of http2, cert manager

(Origin server http, I own) + (Cloudfront CDN, AWS owns=cert manager+reverse proxy+WAF+https+http2)

I was hoping some round trip time saved by browser's geolocation to CDN edge + http2 benefits)

Does that make sense?

ajayg’s picture

Status: Postponed (maintainer needs more info) » Active
Wim Leers’s picture

Status: Active » Fixed

So I guess approx 8 years.

Wow!

With amazon cloudfront, I could just create one distribution, use free TLS cert on AWS cert manager on cloudfront, map all https to pass through it. Although I know it won't be caching, it still provide multiple other benefits as distributed reverse proxy, WAF(Web app firewall), DDOS protection etc which I don't need to worry.

It's also a huge SPOF (Single Point of Failure). CloudFront & CloudFlare have been known to go offline and take huge portions of the internet with it.

If you're putting your entire origin behind a CDN, you don't need the CDN module. Like I wrote at #1579902-3: Support for dynamic content?:

This doesn't actually make sense to do in the CDN module.

See http://wimleers.com/talk/caching-at-the-edge-cdns-for-everyone — Drupal 8 is able to easily integrate with any CDN even for dynamic content as long as it supports tag-based invalidation. To integrate with such CDNs, use https://www.drupal.org/project/purge. Currently the Fastly and CloudFlare CDNs support cache tags.

And the project page also says this:

It does not put your entire website behind a CDN.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.