Search code examples
joomlabrowser-cachevirtuemart

How to browser cache image from php


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?


Solution

  • 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.