Hello,

I have a Symfony application in which I must redirect hits to images
to signed URLs in an Amazon S3 bucket. I have checked the code that
creates the signed URLs; they are created correctly and two
consecutive hits in a small time interval will result in an identical
URL being created.

The problem is that the images are not cached properly. As far as I
can tell, Amazon sends the cache control info correctly and they are
not re-requested from there..

It seems that the redirect to amazon is not cached, so my site gets
hit on each page load for each image. I am using a 301 redirect. Code:

$this->getResponse()->addCacheControlHttpHeader("max_age=60");
$this->getResponse()->setHttpHeader('Expires', $this->getResponse()-
>getDate(time()+57200));
$this->redirect(S3Storage::GetImageURL($img->getID()."_thumb.jpg"),
301);


HTTP exchange:

GET /thumb/13 HTTP/1.1
Host: <...>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:
1.9.1.9) Gecko/20100315 Firefox/3.5.9
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en,ro-ro;q=0.8,ro;q=0.6,en-us;q=0.4,en-gb;q=0.2
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: <...>
Cookie:
__utma_a2a=2324303139.1301076973.1269520047.1272671147.1272671181.1608;
symfony=ks1bdtm0ghfkhv2felaos52ao4

HTTP/1.1 301 Moved Permanently
Date: Fri, 30 Apr 2010 23:46:51 GMT
Server: Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k
mod_autoindex_color PHP/5.3.0 mod_perl/2.0.4 Perl/v5.10.0
X-Powered-By: PHP/5.3.0
Location: http://<...>.s3.amazonaws.com/13_thumb.jpg?AWSAccessKeyId=<....>
Content-Length: 222
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8



Any ideas what I could do to make caching work?

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to