title: Performance issue with React deployment on AWS S3
body: <p>I have built and deployed React app (let's call it app A) on S3 and enabled "Static website hosting" for it. This app was earlier running on an EC2 instance using Node. Recently, someone from the team deployed another React app (B) on S3 and that's when I read that S3 can be a good option to easily deploy static content so I thought of moving app A to S3. However, after deploying the app, I see that it's taking too much time (10-15 secs) to even get the login page. After I login, the experience is not that bad but slowness is still evident. This wasn't the case when it was running on EC2 instance.</p>
  
  <p>Just to clarify, all these React-based apps including app A and B, are meant to be used within the company's network only and all the users are from US region only. App A fetches images (and other data) from other React-based apps (apps B and C, both hosted on S3 only) and from other application (running on EC2 instance).</p>
  
  <p>I read about performance issues and came across <code>content-encoding</code> and <code>cache-control</code> parameters that can be used while uploading the build to S3. I zipped the CSS and JS files using GZIP and also added metadata for <code>content-encoding</code> however, I couldn't notice any significant difference in page load. I left <code>cache-control</code> parameter (i had set it to <code>max-age=31536000</code> because app A had <em>hashed</em> file names) because after adding this parameter, i was getting blank page (not sure why) after logging into the application. I also checked the site performance using GTMetrix (snapshot attached). In this report, you will notice that it's still showing that compression can be improved however, the recommendations are actually for app B that this app A connects to. I think this is an improvement area for me. I also checked with the developer and he told me that he has not used compression internally in the application (app A) although I compressed it when uploading it to S3.</p>
  
  <p><a href="https://i.stack.imgur.com/Cr6BV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Cr6BV.png" alt="enter image description here"></a></p>
  
  <p>I have read many articles where people used S3 with CloudFront or other CDNs. I am not sure what's the right approach to my issue as i am doing such deployment for the first time. I also have to take cost into consideration before proposing S3 as a deployment method for other environments (QA, UAT, PROD).</p>
  
  <p>Considering that the application users will be <em>within</em> the company's network only, i have following queries:<br>
  1) Can CloudFront/CDN approach be avoided or is it the only way i can fix this performance issue?<br>
  2) If static hosting on S3 is fine, then can some modification be done to the overall setup so that images fetched (from the other S3 hosted React app C) do not get routed through the Internet, thus saving on cost?</p>
  
  <p>I just checked the S3 bucket size for React app C where most of the images reside. As of now, the total bucket size is around 200 MB and the maximum file size i could see for an image was around 100 KB (most are in that range). Please let me know if more data is needed to provide a suggestion.</p>