cancel
Showing results for 
Search instead for 
Did you mean: 

Cached Images not shown in Product Image (CDN at AWS S3)

Highlighted

Cached Images not shown in Product Image (CDN at AWS S3)

I am stuck here. As i am using S3 bucket and S3FS-FUSE for syncing my /media folder with S3 bucket with rsync (cronjob).

 

As rsync is very slow in syncing cached images with S3, thus it results in broken image links on main product pages as cached images are not present in S3.

 

This is actually a known problem with the CDN, i am also not able to figure out any workout.

Is it possible to modify some code in magento 1.9.3.4 for MAIN PRODUCT IMAGE in .phtml that shows main product image, that magento will load only original images from CDN S3, not the cached images.

7 REPLIES
Magento
E-Commerce

Re: Cached Images not shown in Product Image (CDN at AWS S3)

I'm not sure how you have magento configured to point to images on the CDN. In core Magento, it uses an image helper when getting product media URLs which references the media/catalog/product/cache folder which sounds like what you want to avoid. 

 

You can see how it uses the image helper for the main product image in the base theme on this line: https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/design/frontend/base/default/templat...

and this one

https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/design/frontend/base/default/templat...

 

The gallery images are on this line https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/design/frontend/base/default/templat...

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Cached Images not shown in Product Image (CDN at AWS S3)

@Tom Robertshaw

I am using S3FS-FUSE

I have synced /media folder with S3 bucket and using cdn.domain.com (as bucket name), thus URL i have updated in unsecure & secure URL for /media in magento.

 

There are two major problems i am facing:-

1. Image cache broken links (already explained)

2. If i import new products, lets say 200 product having 300 images. rsync is so slow that it may take 1 hour to sync that images to S3.. In that meantime, the product images link will be broken.

Any resolution to this? Or how to achieve this with any different solution?

 

AIM: My aim is just to upload my product images to S3 or also i can use cloudfront so that it could unload some load from my server.

NOTE: Why i am not using cloudfront as my whole customer base is specific to one country only.

 

(I am using magento CE 1.9.3.4 presently 60,000 products and in 1 month it will be more than 1,50,000)

Magento
E-Commerce

Re: Cached Images not shown in Product Image (CDN at AWS S3)

As I understand S3fs-fuse from reading around, the s3 bucket should be mounted on the filesystem (https://magento.stackexchange.com/a/68933/26) which would suggest you shouldn't need rsyinging via cron. Have I misunderstood the setup?

 

If you do need rsync for your setup I would recommend using the aws cli tool which has a sync command which will probably be quicker/more suited https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html. 

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Cached Images not shown in Product Image (CDN at AWS S3)

@Tom Robertshaw

yes you are right. I have mounted it.

 

CLI also takes time.. I couldnt find anywhere it is fast or quick.

But i wonder if there is any other solution to achieve what i want to achieve?

Magento
E-Commerce

Re: Cached Images not shown in Product Image (CDN at AWS S3)

Hmm, sounds like anything that has to routinely sync is going to struggle in your environment. Perhaps it's time to consider some alternatives. You could use Cloudflare which is really simple to set up. Or if you want to stick with Amazon you could try Cloudfront. This post from  inchoo seems like a good guide http://inchoo.net/magento/set-up-cdn-in-magento/

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Cached Images not shown in Product Image (CDN at AWS S3)

@Tom Robertshaw

while i figured out some alternatives.

 

I configured https://github.com/thaiphan/magento-s3/

But still things are same. cache images links are broken, but they are not supposed to be broken using this extension.

 

Am i missing something in S3?

Magento
E-Commerce

Re: Cached Images not shown in Product Image (CDN at AWS S3)

Sorry, I'm not sure what that could be.  This extension appears to override the file storage model so in theory anything that tries to be written to file would be written to s3 instead so from that I'd expect it to write the cache files in s3 too. 

 

You're probably going to need to get a developer involved to look at it more closely I'm afraid. 

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!