store gzipped cache pages

killes@www.drop.org - June 14, 2004 - 19:06
Project:Drupal
Component:base system
Category:task
Priority:normal
Assigned:killes@www.drop.org
Status:closed
Description

Drupal has a rather efficient page cache for anonymous users. Also, there exist mod_gzip a module for Apache which will send the data compressed which saves bandwidth. however, mod_gzip will compress each served cache page anew. Since we generate the page cache in Drupal it is easy to also compress it and store it that way. Benchmarks indicate that a performance increase of about 13% can be achieved.

Further improvements could come from the fact that the cache table will be smaller and thus selects should be faster. My cache table was almost empty.

I still need to investigate under which circumstances gzencode uses the deflate or the zlib algorithm.

The docs seem to indicate that it would be gzip, but on my servers it is deflate. I wasn't successfull on finding anything on google so any insight any of you has to share would be appreciated.

This is important when inflating the cache again for old browsers that cannot handle gzipped pages (a very small minority of today's requests).

The attached patch has been well tested and not caused any trouble.

AttachmentSize
txt00005.txt1.07 KB

#1

killes@www.drop.org - July 7, 2004 - 09:34

That's a patch, actually.

#2

killes@www.drop.org - July 7, 2004 - 10:20

Updated to apply to CVS, changed a bit after consultation with Steven.

AttachmentSize
gzipped-cache.patch1.44 KB

#3

Dries - July 7, 2004 - 22:36
  1. What happens when Apache itself does gzip compression as well? Wouldn't that be a waste of resources?
  2. The fact pages are potentially gzipped ought to be documented in the help text.
  3. I'd also like to see the cache_set() line broken apart in multiple lines using regular if-else constructs.

#4

killes@www.drop.org - July 7, 2004 - 23:14

1) Apache should detect that the output has been compressed already (we set the right header). If it doesn't it is broken.

2) True. To which help text should I add this? Also, this needs a database update:

delete from cache;

3) done.

AttachmentSize
gzipped-cache.patch0 bytes

#5

Dries - July 8, 2004 - 07:25

There is a section about Drupal's cache system in the system module's help. I suggest adding it there.

Some more thoughts:

  • Should images/files be compressed? I'm afraid some of them end up in the cache too -- or at least, they used to. Maybe that's something we should fix first?
  • I vagelue remember some applications send a 32-bit CRC as well. It might only be for gzip compression, not for zlib compression.
  • Can PHP's "ob_gzhandler" be used?

#6

killes@www.drop.org - July 8, 2004 - 19:05

Here is an updated patch that includes helptext and update.inc. info. the other problems mentioned by Dries were probably solved long ago.

AttachmentSize
gzipped-cache_0.patch4.39 KB

#7

Dries - July 8, 2004 - 19:22

Committed to HEAD.

#8

Anonymous - July 22, 2004 - 20:20

#9

el777 - April 5, 2006 - 09:19
Version:» 4.6.5
Status:closed» active

I found one bad bug when storing cached pages and working with mod_deflate.

My server: Apache/2.0.55 + PHP 5.1.2 as FastCGI
If cache and mod_deflate are enabled then anonymous pages are incorrect and cannot be showed to user. I tried to debug it with Fiddler - it showed length is transmitted incorrectly. I think it's due to the Apache attempt to compress already compressed page. So header Content-Length becomes incorrect. Of cource double-compressed page cannot be showed well.

Now I have to disable deflate for drupal-based site.

#10

magico - August 21, 2006 - 16:26
Status:active» closed

Closing this again.

@el777: you should had open a new issue and not reopen this one almost two years old.

#11

killes@www.drop.org - August 23, 2006 - 09:28

In case anybody else is stumblign over this: I've tried this with apache2 (albeit not as fcgi) with mod_deflate and couldn't reproduce this.

 
 

Drupal is a registered trademark of Dries Buytaert.