Search code examples
amazon-web-servicescloudload-balancingcdnsaas

how to serve content from CDN to non logged users and from actual webapps to logged ones?


I wonder, for example using AWS, if it was possible to detect the session of the user and send him to CDN if no session, or to the actual servers if logged in. Any ideas? I'm not too practical of CloudFront or Load balancers. Feel free to give examples using other cloud providers or Saas.


Solution

  • The CloudFront CDN has an integration with AWS Lambda, which allows you to intercept, inspect and modify requests at various points in their lifecycle. This is called Lambda@Edge.

    You can use an Lambda@Edge function to dynamically select an origin as the source for the data based on information like the headers. AWS has published a blog post that describes this process in more details.