We use Amazon S3 storage to host images and its thumbnails. We upload new images without its thumbnails to generate it on demand. To do it, we use S3 rewrite rules which look like this:
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>mysite.com</HostName>
<ReplaceKeyPrefixWith>/path/to/thumbnail/generator.php?image=</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
If a thumbnail doesn't exist yet, it will be redirected to our script, which generates a new thumbnail, uploads to S3 and sends it in a response. The script works fine and does what we need. The problem is that all next calls to the newly generated thumbnails are redirected to the script again and again event if a thumbnail is already available in the S3 bucket...
How can I stop "next redirects"?