AWS/image trouble
Closed this issue · 9 comments
Good morning!
I have two maybe-related issues with our S3 bucket:
- I can't name or rename new folders in our image directory
- I've uploaded some images that weren't showing up, here: https://opennews-source-staging.herokuapp.com/articles/what-open-really-means-538-vox-and-upshot/ (the two inline figures) and the paths are correct, but the images don't display, and I can't figure out why.
I'm hitting the same issue with this article: https://opennews-source-staging.herokuapp.com/articles/how-and-why-we-made-twitter-reverb/
Note: I'm uploading the images into the uploads
area so that I can ideally just upload them without manually adjusting all the paths already in the article. When I do that, they're reachable this way:
https://s3.amazonaws.com/media.opennews.org/img/uploads/article_images/05_bringhome.jpg
…but not this way:
https://media.opennews.org/img/uploads/article_images/05_bringhome.jpg
Maybe there's something I'm doing wrong?
Also I seem not to have the ability to check or change file permissions via FTP, so I haven't been able to see if that's related.
(And I wasn't able to try uploading them into their own folder in the regular images area, because I can't name any folders.)
I was able to discover that if I rename the image in the uploads folder, and then rename it in the path in the img tag in the article, it shows up. (But I don't have permissions to rename them for real, just to dupe them, which makes a new one with "copy" in the filename.)
Is that a caching thing that can easily be blown up, or should I just be renaming them once I get permissions to do so?
AHHH! I'll check the permissions on the S3 user account to see if I can figure out what's happening. Will put some notes about Cloudfront in a separate comment, but first, quick question about this issue here:
Note: I'm uploading the images into the uploads area so that I can ideally just upload them without manually adjusting all the paths already in the article. When I do that, they're reachable this way:
https://s3.amazonaws.com/media.opennews.org/img/uploads/article_images/05_bringhome.jpg
…but not this way:
https://media.opennews.org/img/uploads/article_images/05_bringhome.jpg
Maybe there's something I'm doing wrong?
Both of those links work for me. Does the second one still not work for you?
Both of those links work for me. Does the second one still not work for you?
THEY DO NOW hey therrrre
OK, so at least some of the weirdness you were experiencing is due to Cloudfront caching. We've got that enabled for performance reasons, and because it lets us force delivery of assets via https.
-
Existing items in the cache are stored for a day. Which explains why changing a file in S3 didn't result in a change on site, but changing the reference to a new path did work. I'm inclined to leave the cache time alone here, unless we think that going forward it'll be a regular occurrence that we'll need to change files in place (and not just something we're running into in this initial crush). Thoughts?
-
When a requested item is missing from the cache, Cloudfront caches that 404 response for 5 minutes, and then tries again. That probably explains why the
https://media.opennews.org
image above wasn't showing up at first, but is working fine now.
unless we think that going forward it'll be a regular occurrence that we'll need to change files in place (and not just something we're running into in this initial crush). Thoughts?
Hmm. We do have to swap out images during production and shortly after publication pretty frequently, butif we know that we have to always rename them to do that, I guess it's fine? @tsl-lindsay, any thoughts?
When a requested item is missing from the cache, Cloudfront caches that 404 response for 5 minutes, and then tries again. That probably explains why the https://media.opennews.org image above wasn't showing up at first, but is working fine now.
"It was just caching" is always my favorite answer ever.