问题
I use virtuemart. There are a lot of images about the products. But this images come from a php file(imgtag.php), so I can't force the browser with this code to take the product images to the cache:
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|ttf|eot|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
Example for product image URL:
http://www.myshop.com/components/com_virtuemart/show_image_in_imgtag.php?filename=be6160cc3ede6b58d13f4adaa61f49f7.jpg&newxsize=120&newysize=120&fileout=
How can I do this?
回答1:
You could modify your imgtag.php
file, so it sends that header, using the PHP header() function :
header('Cache-Control: max-age=2592000');
Note : setting headers must be done before any output.
来源:https://stackoverflow.com/questions/5316829/how-to-browser-cache-image-from-php