minifying the website

Adam D. Ruppe destructionator at gmail.com
Fri May 31 10:50:06 PDT 2013


On Friday, 31 May 2013 at 17:23:49 UTC, Andrei Alexandrescu wrote:
> I don't know if the server is configured to serve them gzipped. 
> How do I figure that out?

I'd just upload a file.html.gz (gzip file.html on your own 
computer) and then try to go to dlang.org/file.html

It might just work. If that doesn't, rename file.html.gz to 
file.html and again try it, if it just works, add gzip to your 
build process then upload.

If it doesn't just work, and .htaccess is enabled, try adding 
this to your .htaccess file and then try again:


<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{HTTP_USER_AGENT} !Safari
    RewriteCond %{REQUEST_FILENAME}.gz -f
    RewriteRule ^(*.html)$ $1.gz [QSA,L]
<FilesMatch \.html\.gz$>
    ForceType text/html
    Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
<IfModule mod_mime.c>
    AddEncoding gzip .gz
</IfModule>


that just does html, the regexs will need matching for js and css 
too, but that should work. I use this on one of my computers to 
serve up file.html.gz as file.html transparently.

BTW I suck at apache config and hate doing it (this is why my 
cgi.d has a gzip flag among others - easier to do in D than 
httpd.conf!) so if someone has a better way please overrule me.

> Can we count on all modern browsers to ask for gzipped content?

Yeah, and if not the server will most likely unzip it for you as 
needed.


More information about the Digitalmars-d mailing list