I dynamically generate svgz images with php, for example:
<?php
header("Content-Encoding: gzip");
header("Content-Type: image/svg+xml");
$wth=1280;$hth=180;
$hd="<svg width='".$wth."' height='".$hth."' viewBox='0 0 ".$wth." ".$hth."' xmlns='http://www.w3.org/2000/svg' version='1.1'>";
$hd.="<rect x='0' y='0' width='".$wth."' height='".$hth."' fill='green'/>";
$rad=25;$ncr=20;$rcv=['yellow','gray','red'];
for($c=0;$c<$ncr;$c++){$hd.="<circle cx='".mt_rand($rad,$wth-$rad)."' cy='".mt_rand($rad,$hth-$rad)."' r='".$rad."' fill='".$rcv[mt_rand(0,count($rcv)-1)]."'/>";}
$hd.="</svg>";
echo gzencode($hd,9);
?>
In my htaccess file I add:
ExpiresActive on
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/svg+xml "access plus 60 seconds"
ExpiresDefault "access plus 0 seconds"
but it does NOT work as expected, and the php-svg image file shows always a 200 OK status I tried also simply:
ExpiresActive on
ExpiresByType image/png "access plus 1 month"
ExpiresDefault "access plus 60 seconds"
(this doesn't suit my needs as I wish 0 seconds for all other html/xml files) but also this way the php-svg image is not cached and comes out with 200 OK
Note that also the other php files, served as html are not cached (???)
In both cases the png files are cached as expected and deliver a 304 status
I tried also to add a
ini.set('session.cache_limiter','public')
ini.set('session.cache_expire',60)
directly in the php-svg file with no result
Note that in my php.ini file the settings are
session.cache_limiter = nocache
session.cache_expire = 180
What's going wrong ? Is there a issue related to some php.ini configuration ? Does htaccess overrides php.ini or not ? Is there a solution not requiring any modification to php ini ?
Any help very welcome !
Giovanni (my website: http://isbooth.com )