Sorry, couldn't wait until 1 year anniversary of last post...
I've been poking around with optimizing my sites' performance over the last few days, and found a real nice tool called SmartOptimizer. SmartOptimizer is acts as a middle-ware between your data and your webserver. When a request is made, .htaccess will pick up, and forward specific file(s) to the optimizer, particularly, images, css, and static HTMLs. This is useful because the optimizer can then compress them using gzip, cache the compressed file, add some http header information to help caching, and serve the compressed optimized file. However, using GTmetrix, I found out that some things are missing, so I decided to add some fixes.
GTmetrix suggested static content should send "Vary: Accept-Encoding" http header, because some public proxies will not cache things properly. And I've found the most effective way to add this is to add the said header in index.php like so:
Find in index.php:
header("Last-Modified: " . $mtimestr);
header("Cache-Control: must-revalidate");And replace with:
header("Last-Modified: " . $mtimestr);
header("Vary: Accept-Encoding");
header("Cache-Control: must-revalidate");
Another recommendation made was that some files did not had a far enough future expire date. As such, I've modified my index.php to output a further expiry date for most documents. This is not required, and may cause funny caching if your static HTMLs are updated frequently. But, if you want to change it, you may do so like this:
Find in index.php:
if (!$settings['clientCache'] || !$settings['clientCacheCheck'] || !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || $_SERVER['HTTP_IF_MODIFIED_SINCE'] != $mtimestr) {Add before it:
// 1 year far future expire time:
$now = time();
$mtexpirestr = gmstrftime("%a, %d %b %Y %H:%M:%S GMT", $now + 31550600);Then, find:
header("Last-Modified: " . $mtimestr);
header("Cache-Control: must-revalidate");*may be different if you did the previous modification.
Replace with:
header("Last-Modified: " . $mtimestr);
header("Expires: " . $mtexpirestr);
header("Cache-Control: must-revalidate");And that should be it... You get a little bit more caching done on client's end, which hopefully in turn will save you some bandwidth, as well as offer your visitors a snappier browsing experience. Hope this helped!