I have a website (powered by Tomcat on Elastic Beanstalk) that generates an artist discography (one page for one artist). This can be resource-intensive, since the artist’s pages do not change for a month, I put CloudFront Distribution in front of him.
I thought this meant that not one request from the executor should ever be served by my server more than once, but it is not so good. This post explains that each location of the edges (Europe, USA, etc.) will be skipped when you first view the resource and that there is a limit on the number of resources stored in the cloud cache so that they can be discarded.
So, to meet this, I changed the server code to save a copy of the web page in a bucket in S3, and check it first when the request arrives, so if the artist page already exists on S3, then the server extracts it and returns its contents as web pages. This greatly reduces processing, as it only once creates a web page for a particular artist.
But:
- The request still needs to go to the server to check if the artist page exists.
- If the artist page exists, the web page (and sometimes can be large up to 20 MB) is first uploaded to the server, and then the server returns the page.
So, I wanted to know if I could improve this - I know that you can build an S3 bucket as a redirect to another site. Is there a way for each page, can I get the artist’s request to go into the S3 bucket and then return it if it exists, or call the server if it is not?
Alternatively, I can get the server to check if the page exists, and then redirect to the S3 page, and not load the page to the server first?
java amazon-s3 amazon-web-services amazon-cloudfront
Paul taylor
source share