WebPagetest Forums
Can't configure apache to clear all F grades! - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: Web Performance (/forumdisplay.php?fid=3)
+--- Forum: Optimization Discussions (/forumdisplay.php?fid=5)
+--- Thread: Can't configure apache to clear all F grades! (/showthread.php?tid=9411)

Can't configure apache to clear all F grades! - johnnypoll - 11-24-2011 07:26 PM

If anyone with apache knowledge can advise, I would be very grateful.

I spent a day trying to optimise my httpd.conf and did see good improvements but have reached the end of my limited understanding.

This is where it has got to: http://www.webpagetest.org/result/111124_Y7_29JE7/

One bit that is bugging me is my failure to GZIP encode all text assets (the main html file):

FAILED - (43.8 KB, compressed = 6.1 KB - savings of 37.7 KB) - http://www.glovesonhand.co.uk/wa/1/43/4431-All-Ladies-Fashion.html

The apache config I added was:

<FilesMatch "\.(php|css|htm|html|xml|txt|js|pl|jpg|jpeg)$">
SetOutputFilter DEFLATE

This did apparently compress the CSS file, but not the main page html file.

My other problem is in compressing images. If I tell apache NOT to compress jpg/jpeg files, then the initial load is 2s (25%) slower for this page. However, WPT still gives me a F and still lists the same jpg files as needing compression, even when I am compressing them and the page load is clearly faster.

Now I know a better solution would be to compress images before hand, not on the fly, but why does WPT show a faster load but still report the problem? Is it because it is simply unhappy with what it finds after unpacking the images, despite the fact they were handed over compressed? Is my only fix to better optimise the original images on this site? If so, any Mac OS X / Windows tools I can drop lots of files in and have them come out lighter (so our staff can do the work, not me using command line tools!).

Thanks for any insights, would love straight A grades!


RE: Can't configure apache to clear all F grades! - pmeenan - 11-27-2011 02:34 AM

Are the html files actually html files on disk or are they using a rewrite rule to go to php or some other dynamic language?

As far as image compression goes, you won't be able to do that through apache - you don't want to gzip images. You need the jpeg images to be compressed at a lower image quality and you could either do it as a batch process or do it as part of the publishing process but you don't usually want to do that inline. It shouldn't be too hard to throw together a script that uses imagemagik to recompress all images to a quality level of 75 or 85.

I don't know how possible it would be on your platform but if you could combine the individual images for each color into a combined image (and use an image map or sprite) you could eliminate a lot of the individual image requests and speed things up a LOT.

RE: Can't configure apache to clear all F grades! - johnnypoll - 11-28-2011 08:46 PM

The HTML files are dynamically generated by an app server behind the web server (using Apple WebObjects). Can this not then be compressed on the way out, or do I need a different apache config?

Thanks for the image compression techniques, we have gone through this process and now all is ok on that front.

Thanks also for the tip on using a single image with image map. I have started to understand that numbers of resources / round trips is a key problem in performance.


RE: Can't configure apache to clear all F grades! - pmeenan - 11-28-2011 11:41 PM

You can do it by mime type instead of just file extension:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain    
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE text/xml    
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/json

That should work a bit better for dynamically generated content.

RE: Can't configure apache to clear all F grades! - johnnypoll - 11-29-2011 02:49 AM

I had actually tried that route and the same results (it is in place now). The source for the page contains:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

which I assume should match on "text/html"?


RE: Can't configure apache to clear all F grades! - pmeenan - 11-29-2011 02:53 AM

Check the actual HTTP headers. Apache doesn't look at meta headers within the payload. There could also be another rule somewhere else that may be breaking it (check your htaccess and httpd.conf for downgrade or force-response-1.0

RE: Can't configure apache to clear all F grades! - johnnypoll - 11-29-2011 03:12 AM

Well, there was (now commented out):

#BrowserMatch "Mozilla/2" nokeepalive
#BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
#BrowserMatch "RealPlayer 4\.0" force-response-1.0
#BrowserMatch "Java/1\.0" force-response-1.0
#BrowserMatch "JDK/1\.0" force-response-1.0

Here is what curl says about the headers:
curl -I http://www.glovesonhand.co.uk
HTTP/1.1 200 Apple
Date: Mon, 28 Nov 2011 17:09:11 GMT
Server: Apache/2.2.21 (Amazon)
connection: close
content-length: 12819
Content-Type: text/html; charset=UTF-8

still doesn't want to compress the main file returned

Thanks for your amazing help to this point and no problem if you don't have further ideas.

RE: Can't configure apache to clear all F grades! - pmeenan - 11-29-2011 04:15 AM

Sorry, you've reached beyond my area of expertise (particularly with the Apple Web Objects side of things). It might be worthwhile to see if you can gzip directly at the app server, particularly if Apache is proxying the requests through and not running it as a cli.

RE: Can't configure apache to clear all F grades! - johnnypoll - 11-29-2011 08:26 PM

I have found a WebObject thread that touches on this: http://osdir.com/ml/webobjects-dev/2011-02/msg00188.html
which suggests that there should be a config file for that adaptor specifically e.g. /Library/WebObjects/ Adaptors/Apache2.2/apache.conf containing:
SetOutputFilter DEFLATE
though that file path is a MacOS path and I can't see an equivalent config file on Amazon Linux
I will try to resurrect the thread and that list and post back if I find a solution.
Zipping at the app server is possible using a framework called Wonder, though I am not currently using that framework.