Link to home
Start Free TrialLog in
Avatar of patricktam
patricktam

asked on

AWS Cloudfront disable caching and forward all parameters to the origin

Hi Expert,


Recently, we have encountered HTTP 504 error on the client browser when access our origin server via AWS Cloudfront CDN service. The issue seems to be persist for quite some time until our Cloudfront service provider decided to disable caching and forward all parameters to the origin.  Once they have done so disable caching and forward all parameters to the origin, seems that the performance improved and no HTTP 504 error shown on the client side. We are not familiar with the AWS cloudfront CDN infrastructure and have the following questions:


1) Why is disable caching and forward all parameters to the origin can actually improve the client side performance issue and resolve the HTTP 504 error ?


2) Is it practical or any side effect if we disable caching and forward all parameters to the origin when we proceed to the system production stage ?


Thank you for your technical advice in advance.


Regards

Patrick

ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of patricktam
patricktam

ASKER

Hi Expert,


Thanks for the comment. Instead of forward all the parameters from Cloudfront to the origin, I was wondering if we can choose some selecting parameters and test it one by one to make sure the 504 error won't happen again. But it is NOT an easy task of choosing which parameters to forward and which to cache. Any other advice on this aspect.


Thanks & Regards

Patrick

Choosing parameters... what are you currently using?

You can customise the parameters that get sent by using Lambda@Edge. 


https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html


Lambda@Edge lets you run Node.js and Python Lambda functions to customize content that CloudFront delivers, executing the functions in AWS locations closer to the viewer. The functions run in response to CloudFront events, without provisioning or managing servers. You can use Lambda functions to change CloudFront requests and responses at the following points:

  • After CloudFront receives a request from a viewer (viewer request)

  • Before CloudFront forwards the request to the origin (origin request)

  • After CloudFront receives the response from the origin (origin response)

  • Before CloudFront forwards the response to the viewer (viewer response)

 

User generated image


We've created a customized cloudfront Cache Policy (15 TTLs) and customized Origin request policy (All viewer and forward all parameters in viewer request to the origin) and seems remediate the HTTP 504 error. 


Thanks a lot. 

The technical advice is useful. Thanks a lot.