@@ -1318,6 +1318,56 @@ if [ "$SECONDARY_HOSTNAME" != "" ]; then
13181318 fetch_until -save -recursive $URL \
13191319 ' fgrep -c 150x100xOptPuzzle.jpg.pagespeed.ic.' 1
13201320
1321+ if [ -z " ${DISABLE_PHP_TESTS:- } " ]; then
1322+ function php_ipro_record() {
1323+ local url=" $1 "
1324+ local max_cache_bytes=" $2 "
1325+ local cache_bytes_op=" $3 "
1326+ local cache_bytes_cmp=" $4 "
1327+ echo http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --save-headers $url
1328+ OUT=$( http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --save-headers $url )
1329+ check_from " $OUT " egrep -iq ' Content-Encoding: gzip'
1330+ # Now check that we receive the optimized content from cache (not double
1331+ # zipped). When the resource is optimized, "peachpuff" is rewritten to its
1332+ # hex equivalent.
1333+ http_proxy=$SECONDARY_HOSTNAME fetch_until $url ' fgrep -c ffdab9' 1
1334+ # The gzipped size is 175 with the default compression. Our compressed
1335+ # cache uses gzip -9, which will compress even better (below 150).
1336+ OUT=$( http_proxy=$SECONDARY_HOSTNAME $WGET -O - \
1337+ --header=" Accept-Encoding: gzip" $url )
1338+ # TODO(jcrowell): clean up when ngx_pagespeed stops chunk-encoding static
1339+ # resources.
1340+ bytes_from_cache=$( echo " $OUT " | wc -c)
1341+ check [ $bytes_from_cache -lt $max_cache_bytes ]
1342+ check [ $bytes_from_cache $cache_bytes_op $cache_bytes_cmp ]
1343+ # Ensure that the Content-Encoding header matches the data that is sent.
1344+ OUT=$( http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP \
1345+ --header=' Accept-Encoding: gzip' $url \
1346+ | scrape_header ' Content-Encoding' )
1347+ check_from " $OUT " fgrep -q ' gzip'
1348+ OUT=$( http_proxy=$SECONDARY_HOSTNAME $WGET -O - $url )
1349+ bytes_from_cache_uncompressed=$( echo " $OUT " | wc -c)
1350+ # The data should uncompressed, but minified at this point.
1351+ check [ $bytes_from_cache_uncompressed -gt 10000 ]
1352+ check_from " $OUT " grep -q " ffdab9"
1353+ # Ensure that the Content-Encoding header matches the data that is sent.
1354+ # In this case we didn't sent the Accept-Encoding header, so we don't
1355+ # expect the data to have any Content-Encoding header.
1356+ OUT=$( http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $url )
1357+ check_not_from " $OUT " egrep -q ' Content-Encoding'
1358+ }
1359+ start_test Cache Compression On: PHP Pre-Gzipping does not get destroyed by the cache.
1360+ URL=" http://compressedcache.example.com/mod_pagespeed_test/php_gzip.php"
1361+ # The gzipped size is 175 with the default compression. Our compressed
1362+ # cache uses gzip -9, which will compress even better (below 150).
1363+ php_ipro_record " $URL " 150 " -lt" 175
1364+ start_test Cache Compression Off: PHP Pre-Gzipping does not get destroyed by the cache.
1365+ # With cache compression off, we should see about 175 for both the pre and
1366+ # post optimized resource.
1367+ URL=" http://uncompressedcache.example.com/mod_pagespeed_test/php_gzip.php"
1368+ php_ipro_record " $URL " 200 " -gt" 150
1369+ fi
1370+
13211371 # Verify that downstream caches and rebeaconing interact correctly for images.
13221372 start_test lazyload_images,rewrite_images with downstream cache rebeaconing
13231373 HOST_NAME=" http://downstreamcacherebeacon.example.com"
0 commit comments