Thanks for your response Ben. I did mean the user-agent caching. I guess I can control this using the PHP header output and hope the user-agent respects the header.
Penalties or benefits, depends which way you look at it I guess ;-) Essentially I need to compare the cost of the two statements below assuming a 20K - 50K file <link rel="stylesheet" type="text/css" href=" http://my.domain.com/stylesheet.php?file=/path/to/stylesheet.css"/> <link rel="stylesheet" type="text/css"href=" http://my.domain.com/path/to/stylesheet.css<http://my.domain.com/stylesheet.php?file=/path/to/stylesheet.css> "/> The first one uses a PHP file to get output compression (as described in my previous email - simply loading the file and returning it with compression using ob_gzhandler). The second does the usual. All things being equal, which one will load faster? I can try and get a few tests running but I will hold off in case anyone here knows already. On 21 September 2012 15:57, Ben Johnson <b...@indietorrent.org> wrote: > > > On 9/21/2012 10:10 AM, edward eric pedersson wrote: >> 1) Will apache cache the full url or the url minus the query parameter? > > I don't believe that Apache will cache anything. Did you mean the > user-agent? If so, the user-agent should cache the contents associated > with the entire URL, including the query-string. After all, the > query-string is part of the URL and a one-character change in the > query-string means an entirely different (and potentially unrelated) URL. > >> 2) Are there any performance benefits as there is an overhead in >> calling the PHP file? > > There are definitely no performance benefits. Did you mean performance > penalties? :) > > There are definitely penalties; to what extent they affect your > application depends on how "heavy" the PHP wrapper script is. For > example, if you simply read the CSS file and spit it back out with > compression, it should perform fairly well. > > Also, consider implementing some kind of white-list for your CSS files. > The implementation could range from a simple call to in_array() to a > database query. The goal is to prevent malicious user-agents from > requesting (and receiving) arbitrary files from the file-system. > >> 3) If the PHP call is cached is it cached with the file query parameter? > > Again, I don't believe Apache does any caching in the manner implied. > PHP, however, is capable of leveraging an op-code cache (such as APC). > Unfortunately, I don't know much about its inner-workings. > > For what it's worth, I do this very thing (PHP wrapper script to acquire > CSS and JS files) quite successfully (although, for templating reasons, > not compression). > > Good luck! > > -Ben > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org > For additional commands, e-mail: users-h...@httpd.apache.org > -- -- e