0

Team,

I'm trying to enable GZIP compression in my bluemix php application, but it doesn't seem to work at all.

I've tried both options from this page: https://varvy.com/pagespeed/enable-compression.html and my application http://arkdev.mybluemix.net isn't enabling it. At least, I cannot see in the headers, neither GZIP compression test tools can see it.

This is my current code in htaccess:

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [NC,L]

# Enable GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-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
</ifmodule>

# Expires Headers - 2678400s = 31 days
<ifmodule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 7200 seconds"
  ExpiresByType image/gif "access plus 2678400 seconds"
  ExpiresByType image/jpeg "access plus 2678400 seconds"
  ExpiresByType image/png "access plus 2678400 seconds"
  ExpiresByType text/css "access plus 518400 seconds"
  ExpiresByType text/javascript "access plus 2678400 seconds"
  ExpiresByType application/x-javascript "access plus 2678400 seconds"
</ifmodule>

# Cache Headers
<ifmodule mod_headers.c>
  # Cache specified files for 31 days
  <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
  Header set Cache-Control "max-age=2678400, public"
  </filesmatch>
  # Cache HTML files for a couple hours
  <filesmatch "\.(html|htm)$">
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  </filesmatch>
  # Cache PDFs for a day
  <filesmatch "\.(pdf)$">
  Header set Cache-Control "max-age=86400, public"
  </filesmatch>
  # Cache Javascripts for 31 days
  <filesmatch "\.(js)$">
  Header set Cache-Control "max-age=2678400, private"
  </filesmatch>
</ifmodule>
Ryoji Kuwae Neto
  • 1,027
  • 7
  • 7
  • http://stackoverflow.com/questions/12367858/how-can-i-get-apache-gzip-compression-to-work – Hackerman Aug 25 '16 at 13:02
  • Hackerman, tried all the codes in the link that you've provided and none of them seems to work for me. Any suggestion? I have no idea, my htaccess seems to be right :/ – Ryoji Kuwae Neto Aug 25 '16 at 13:19
  • But, are you sure you have `mod_deflate` enabled? – Hackerman Aug 25 '16 at 13:22
  • No, I don't know where to search for it. IBM Bluemix doesn't let me search through the server files also, i just have the code in the .access and by the comments, they're saying that GZIP is enabled. I've updated my htaccess code for you to see it – Ryoji Kuwae Neto Aug 25 '16 at 13:28
  • Take a look at this answer: http://serverfault.com/questions/555140/apache-mod-deflate-does-not-compress-php-output – Hackerman Aug 25 '16 at 13:32
  • Do you have a virtual server thee right?...If so, you can access the server through ssh, or not? Can you elaborate a little bit more to get a full picture of your scenario? – Hackerman Aug 25 '16 at 13:40
  • @RyojiKuwaeNeto You actually can look through your server files by using the cloudfoundry CLI or bluemix CLI with the files action. Sample invoke: `cf files [appname] /app` should show a dir listing of the app folder on the server. As an alternative, `bx app files [appname] [PATH] [-i INSTANCE]` using the bluemix CLI. – Sanjay.Joshi Aug 26 '16 at 05:51

0 Answers0