Permanent compression of html files in web root

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Permanent compression of html files in web root

Postby luddite » 30. July 2016 21:01

i am playing with a simple system that allows the http://schools-wikipedia.org digital encyclopeda to be searched. its not going to be on any live web server but will be using xampp with the web root being /opt/lampp/htdocs (with slackware 14.2) on an offline i.e Intranet basis. Its to give 3rd world like Ghana an educational resource that doesn't depend on missing libs ( kiwix) .

Anyway its working and since it just uses sqlite3 (serverless) as the db linking key words to relevant .htm pages in the encyclopedia as a href links on the index.php landing page , it can be zipped up and distributed maybe using usb pen-drives. Some people might like to download it (soschildren) have given up on the download & its 5gig so im trying to find ways of reducing it down from 5gig

Now i have read that with live web servers you can have gzip compression enabled so that uncompressed text files like html & htm are compressed on the fly & sent to the client.is there anyway of having just compressed html files with no uncompressed ones in the web root that can be used to serve up web pages to client pc's on the Intranet network?
luddite
 
Posts: 6
Joined: 03. February 2013 14:07
Operating System: slackware14

Re: Permanent compression of html files in web root

Postby Nobbie » 31. July 2016 11:38

luddite wrote:is there anyway of having just compressed html files with no uncompressed ones in the web root that can be used to serve up web pages to client pc's on the Intranet network?


I would try to activate compression either per directory or (if this is still insufficient) per file/files via <FILES> or <FILESMATCH> directive. I think that should work.

See

http://httpd.apache.org/docs/current/mo ... flate.html
http://httpd.apache.org/docs/current/mo ... html#files
Nobbie
 
Posts: 8780
Joined: 09. March 2008 13:04

Re: Permanent compression of html files in web root

Postby luddite » 31. July 2016 16:40

cheers Nobbie will have a read up

Playing around with compression. The wiki is divided into relatively few directories & the simplest way of getting reasonable compression & converting all .htm files to gzip equivalent of fileName.htm to fileName.htm.gz is just by $ gzip -N *.htm

Because its for an Intranet I can control what browsers can accept & make sure Accept-encoding:gzip is in header so i don't need uncompressed files.
mod_gzip looks relevant
luddite
 
Posts: 6
Joined: 03. February 2013 14:07
Operating System: slackware14

Re: Permanent compression of html files in web root

Postby luddite » 01. August 2016 12:38

in htdocs of lampp the encyclopedia is in a "wiki" named directory so route for browser is http://localhost/wiki

by putting in a .htaccess file inside wiki directory with code :

RewriteEngine On
AddEncoding gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]


index.php now checks to see if there is a .gz version available of .htm file . tested with one file & it works , except browser unsure what to do with it & asks for open or download. Guess will have to add header to index.php to accept gz
luddite
 
Posts: 6
Joined: 03. February 2013 14:07
Operating System: slackware14

Re: Permanent compression of html files in web root

Postby luddite » 01. August 2016 19:26

seem to have it working don't know if its of any use to anybody else though

So my main objective was to reduce total file size of the http://schools-wikipedia.org/ download, a modifed index.htm ,a new index.php & an sqlite3 database of around 3/4 of a gig all in a directory called wiki, inside htdocs of xampp on Linux

The school wiki has a directory structure of top level wp inside of which are around 36 sub-directories each containing .htm files so i just gzipped the lot from /wiki using: gzip -N *.htm wp/* -r

this turned all .htm files into .htm.gz with fair compression
then inside wiki i added a .htaccess file with content

Options +MultiViews
RemoveType .gz
AddEncoding gzip .gz
<FilesMatch ".+\.tar\.gz$">
RemoveEncoding .gz
# Note: Can use application/x-gzip for backwards-compatibility
AddType application/gzip .gz
</FilesMatch>

A database search of "cameron" returns an a href url of http://localhost/wiki/wp/d/David_Cameron.htm successfully returns & displays the file wiki/wp/d/David_Cameron.htm.gz ( i know this because now there are no David_Cameron.htm file only a .htm.gz file

i have tweaked httpd.conf slightly not sure if this had any bearing ?
luddite
 
Posts: 6
Joined: 03. February 2013 14:07
Operating System: slackware14


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 9 guests