If a style for an image doesn't exist, Drupal generates links in style with: http://drupal/image/generate/large/public/myimage.png , which on reload turns into http://drupal/sites/default/files/styles/large/myimage.png.

This is bad for a couple of reasons:
* The block itself changes content, so it cannot be cached
* The browser cannot cache the result (image) even if the image is the same
* Upstream proxies cannot handle this type of resource properly

Instead of displaying an image, it should send a HTTP 301 to the actual image path instead where the request most likely is handled by the web server instead if PHP. This also makes it easier for upstream proxies or your own web server to decide how to cache/expire its static content.

Comments

Anonymous’s picture

One alternative to redirecting would be to always link to your static material. If Drupal is the 404 handler, it would pick it up and generate 'on demand'. This _requires_ Drupal being the 404 handler and could use some kind of locking to prevent races - but is as far as I can tell a much cleaner approach to handling image style generation.

Anonymous’s picture

I'm also keen to know why generation links are hidden behind a login. More about that here: http://drupal.org/node/806834

Anonymous’s picture

I can whip together a patch for this, but I still would like to know the reasoning behind not allowing anonymous users to generate images. The code has a minor explanation, but it will still generate a maximum of images, and the malicious user has to know what your thumbnail sizes are called.

quicksketch’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing out this issue as out-dated. Both from this and the linked issue, the explanation doesn't seem to make sense. Drupal does use the same URL both to generate and deliver the image. And there's no "/generate/" path within the URL at any point.

Given the age of this issue and it appears the author no longer has an account, I'm closing this issue.