关于压缩缓存文件

I have a simple system cache, and I would like to know when I zip every file on this cache folder and the when page is requested I unzip it and send it , Does this operation influence good on speed? and will it consume more Memory resources ?

note: the goal is to save space


thanks

You're manually zipping cached files on the server and then manually unzipping them and sending them back to the browser as they're requested?

Yes, this will negatively effect your performance.

Instead, consider using something like mod_deflate to automatically shrink file sizes when sending them to the browser.

If you're running Apache web server, you can enter the following set of code into your .htaccess or apache conf file or check with an online tool if that's working or not

<IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
    <IfModule mod_setenvif.c>
        # Netscape 4.x has some problems...
        BrowserMatch ^Mozilla/4 gzip-only-text/html

        # Netscape 4.06-4.08 have some more problems
        BrowserMatch ^Mozilla/4\.0[678] no-gzip

        # MSIE masquerades as Netscape, but it is fine
        # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

        # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
        # the above regex won't work. You can use the following
        # workaround to get the desired effect:
        BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

        # Don't compress images
        SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
    </IfModule>
    <IfModule mod_headers.c>
        # Make sure proxies don't deliver the wrong content
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
</IfModule>

You can adjust and tweak settings to cache, on the command line you can check if it's zipping the files

curl -I -H 'Accept-Encoding: gzip,deflate' www.domain.com