Search code examples
amazon-s3cachingmeteor

Meteor cache issue with Chromium browsers


I currently have an application running on an old version of Meteor (1.10.1).

And I'm getting an error that seems to be a cache error. When I upload some pictures with a specific user. I have a request to S3 that fails with a CORS error, however the return code is 200.

console output

ERROR 200

There is no specific common point between the images except that these two images are images that have already been uploaded with the same account in the past.

However, when I clear the cache on Chrome for example, I can upload the picture again. But I still get the error on browsers whose cache has not been cleared. BUT if I connect to the same account with two different computers, the error is the same no matter which computer I am on.

Could this be related to how Meteor handles a cache with S3?

I checked the CORS settings on my S3, everything seems to be in order and everything works correctly for 95% of the users.

I also tried with the CORS rules at the most flexible.

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST",
            "GET",
            "HEAD"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAgeSeconds": 10000
    }
]

I also checked if there were similarities in the formats, in the sizes, etc... It just seems that this is a photo that has already been uploaded earlier. That's why I think it's a cache problem.


Solution

  • started to answer to you on your exact question then I changed my mind and deleted so I re-write in a different perspective.

    Please read this: https://www.reddit.com/r/aws/comments/eh6vx1/s3_vs_cloudfront_costs/ There are 9 comments there and some refer to exact price comparison.

    Now that the cost risk is addressed let me get into technicals. With AWS, S3 is storage and Cloudfront is the actual CDN that you are supposed to use. When you create a Cloudfront domain in front your S3, Cloudfront takes care of the CORS and all the rest of security and cacheing. Ideally, you would create a subdomain to your domain and point it to your Cloudfront domain so that the origin of your website and the origin of your CDN are the same (no CORS troubles).

    This discussion in the Meteor forum should help you with the setup of Cloudfront: https://forums.meteor.com/t/s3-file-upload-is-slingshot-still-usable-alternatives/54123/10

    As far as I know, there are no Meteor specifics that affect cache. It is all related to the website/webapp CSP which in Meteor is done in general via a browser policy that runs server-side.