[ka-Map-users] gzip-ing .js
Brent Pedersen
bpederse at gmail.com
Mon Mar 6 17:35:05 EST 2006
works in IE (windows), and FF,Opera on linux. for the versions i have--but
you're right it may not work in all cases.
according to PHP.net, the ob_gzhandler sends non-compressed js if the
browser can not handle gzip. i haven't been able to find any info on when
it doesn't work, only that it 'might not work' in some browsers...
i'm not root on most machines that i have ka-map apps on, so it seems a good
alternative when you cant get mod_gzip or the like installed at will.
-b
On 3/6/06, Paul Ramsey <pramsey at refractions.net> wrote:
>
> Make sure you test this well across multiple platforms before you
> implement. Some browsers are happy to accept gzip encoded HTML, but
> croak when handed .js or .css gzipped.
> P
>
> On Mar 6, 2006, at 8:48 AM, David Bitner wrote:
>
> > I've used this PHP method succesfully with other js for quite a while.
> > Another option in Apache is to use mod_gzip or mod_deflate to
> > compress all html,js, and css that goes through the webserver.
> >
> > On 3/6/06, Brent Pedersen <bpederse at gmail.com> wrote:
> >> hi, just saw this use of php that seems especially applicable to
> >> ka-map
> >> javascript.
> >> you can get php to gzip .js (or .css) files for you. this seems to be
> >> working pretty well. (see code below.) it gets it down to a single
> >> request
> >> of 27K instead of 8 requests totalling > 130K.
> >>
> >> -brent
> >>
> >>
> >> <?php
> >> ob_start ("ob_gzhandler");
> >> header("Content-type: text/javascript; charset: UTF-8");
> >> header("Cache-Control: must-revalidate");
> >> $days = 30;
> >> $offset = 60 * 60 * 24 * $days;
> >> $ExpStr = "Expires: " .
> >> gmdate("D, d M Y H:i:s",
> >> time() + $offset) . " GMT";
> >> header($ExpStr);
> >>
> >> $files = array("DHTMLapi.js", "xhr.js", "jsExpander.js ", "kaMap.js",
> >> "kaTool.js", "startUp.js", "extra.js","testExtents.js");
> >>
> >> foreach ($files as $fi){
> >> print file_get_contents($fi);
> >> }
> >>
> >> ?>
> >>
> >>
> >> _______________________________________________
> >> ka-Map-users mailing list
> >> ka-Map-users at lists.maptools.org
> >> http://lists.maptools.org/mailman/listinfo/ka-map-users
> >>
> >>
> >>
> >
> > _______________________________________________
> > ka-Map-users mailing list
> > ka-Map-users at lists.maptools.org
> > http://lists.maptools.org/mailman/listinfo/ka-map-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/ka-map-users/attachments/20060306/c77ce3c3/attachment.html
More information about the ka-Map-users
mailing list