Monday, November 4, 2013

Re: CakePHP themed + cache + gzip enabled + Avast AV + Chrome == Problem

This is not how you should setup the request compression in CakePHP, please read about CakeRequest::compress(). Even though there is a way to do in php I strongly recommend no to, gzip compression should be done in the webserver

On Monday, November 4, 2013 10:58:19 AM UTC+1, Salines wrote:
Hi people,

I have a problem, wich I can not solve.

on page www.detas.ba I have enabled cache and gzip. Views, css, js, are in the themed folder. (App/View/Themed/Detas/...)

On my computer I use Chrome browser and Avast antivirus program.

When I access a page on eg http://detas.ba/sat/792-Casio_LTP_1230D_1CDF and click quickly to any link (button) on the side, my browser sometimes Download .gz file, instead of displaying the page.

If I leave out any part of the heading combinations (CakePHP themed + cache + gzip enabled +  Avast AV + Chrome), this problem does not occur.

For example, if:

CakePHP themed + cache + gzip enabled + Avast AV + Firefox != Problem
CakePHP themed + cache + gzip enabled + disabled Avast AV + Chrome != Problem
CakePHP themed + cache + gzip disabled + Avast AV + Chrome != Problem
CakePHP without themed layout + cache + gzip enabled + Avast AV + Chrome != Problem

In bootstrap.php I have the following:

CakePlugin::loadAll();
Cache::config('default', array('engine' => 'File'));
 if (Configure::read('debug') < 2) {
@ob_start ('ob_gzhandler');
header('Content-Type: text/html; charset: UTF-8');
header('Cache-Control: must-revalidate');
header("Expires: " . gmdate('D, d M Y H:i:s', time() - 1) . ' GMT');
}

in .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>

#Gzip/deflate
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript text/javascript application/javascript
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent

# BEGIN EXPIRES
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 10 days"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType text/plain "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# END EXPIRES

Does anyone have similar problems, similar experience and solution?

Thank you,

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: