[Plugin: Scripts Gzip] Caching & HTTP-Headers, Filters
-
Hi Edward,
Thanks for developing Scripts Gzip. – I just gave it a test-run on one of my WP installations and the results look very promising.
After the integration I used WebPagetest to verify the improvements. Your plugin did a good job on minifying the JavaScript files though on the re-run that WebPagetest conducts to check for browser caching, I noticed that all requests were executed again.
Looking at the headers I figured that no data was transfered because you’ve defined a 304. Nevertheless the files won’t get cached (I might be wrong at that point) since the expiry is always in the past if the most recent change on every file in the ‘stack’ is longer ago than current time minus expiry.
So I’ve changed
$filetime
in$expires = gmdate('D, d M Y H:i:s', $fileTime+$options['file_expires']) . ' GMT';
totime()
.Here’s a dump of my received headers (domain has been removed):
—
Request Headers:
GET /wp-content/plugins/scripts-gzip/gzip.php?css=wp-content%2Fthemes%2Fstyle%2Fstyle.css HTTP/1.1
Accept: */*
Referer: xxx
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; PTST 2.261)
Host: xxx
Connection: Keep-AliveResponse Headers:
HTTP/1.0 200 OK
Date: Thu, 17 Feb 2011 00:14:25 GMT
Server: Apache
Pragma: public
Expires: Mon, 14 Feb 2011 00:27:39 GMT
Etag: “184ffe9db9b07bfea11622d405abaf37”
Accept-Ranges: bytes
Content-Encoding: gzip
Last-Modified: Mon, 07 Feb 2011 00:27:39 GMT
Connection: close
Content-Type: text/css—
I also added the following line for the cache control:
header('Cache-Control: max-age='.$options['file_expires'].', public');
What do you think?
Another idea: Could you maybe add filters for the expiry time and the blacklist? – That way you gain flexibility and your users don’t have to edit the php-files on updates.
A last question: Since I don’t have more than one css-file on that particular website (and doing gzip in .htaccess anyway) I want to use your plugin solely for js-files. Is there an easy way to comment out a certain line to disable picking up and combining css-files while not breaking your plugin?
Cheers,
Berny
- The topic ‘[Plugin: Scripts Gzip] Caching & HTTP-Headers, Filters’ is closed to new replies.