Image cache and thumbnailing
Submitted by Andrewc on Fri, 2009-06-19 04:53.Price Tapestry
Hi
I want to setup that when the Feed is imported that the images are downloaded and then thumbnailed into 2 sizes.
This I feel is a needed feature with this script.
I have already setup the code that does this on the fly but this I think will put unnecessary strain on the server.
Do you foresee any issues with this?
Hey david
Thanks for reply.. so you reckon the on the fly option would be all I need.
Sounds good to me..
Hi Andrew,
Yes - whilst that is a potential strain on the server, perhaps more of a concern to me would be the level of requests to the merchant's server. Your IP might get automatically banned after, say, just reading the first 10 images... Depending on the number of products in the feeds, you could add a sleep(1); after each image request.
Alternatively, you could make it so that the remote images were requested and your thumbnails generated the first time an image was actually required by your site (i.e. search results or on the product page). This could be implemented easily via a common function to get the image URL, which then either returns the already cached image, otherwise retrieves the image remotely and does the same thumbnail processing as you are doing at import time.
If you go down that route - for the same reasons as before I'd recommend the (non-standard) robots.txt directive to slow down spiders... for example:
User-agent: *Crawl-delay: 2
(allow 2 seconds between requests)
Hope this helps!
Cheers,
David.