hi
I tried to install Smart Optimizer (http://farhadi.ir/works/smartoptimizer) but it didnt work , and the website didnt load the css or js files , I've used SmartOptimizer before with joomla and it worked well.
its probably because of a conflict with the zend framework
so any help how to enable gzip compression using any script.
I want to enable it , because my client is complaining about the slow speed of the website, and its true , because there are many css and js file to be loaded (over 250 KB)
This is actually a great suggestion for Simple Invoices to do. To minifiy + gzip and serve out compressed files js/css. I have added this to our todo list.
As for the best way to do it without waiting for us to implement it, have you tried mod_gzip for Apache?
Just wanted to add:
Website information
Total loading time:
6.8 seconds
Total objects:
77 (292 KB)
External objects:
0
HTML (X)HTML:
1 (26.2KB)
RSS RSS/XML:
0
CSS CSS:
13 (57.4KB)
Scripts Scripts:
11 (188.8KB)
Images Images:
52 (19.7KB)
Plugins Plugins:
0
Other Other:
0
Redirected Redirected:
0
I took most of the js:
Before gzip: 199KB
After gzip: 60.8KB
30% of the previous size.
thanks for the suggestion and thanks steve for that info
minifying is a good idea re css and javascript
just need to make sure when its done that the original files are still there as is and that the minification can be easily redone
- as js and css files get changed regularly
cheers
justin
If you are running on an apache server, you could try using your .htaccess file to speed up your site via gzip and caching. Try adding:
# Apache module to compress text files (CSS/HTML/JS)
#AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/json
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|ico|flv|swf|mpg|mpeg)$ no-gzip dont-vary
Header append Vary Accept-Encoding
# Apache module to cache files
FileETag All
ExpiresActive On
ExpiresByType text/html "access plus 2 hours"
ExpiresByType text/css "access plus 2 hours"
ExpiresByType text/js "access plus 2 hours"
ExpiresByType text/x-js "access plus 2 hours"
ExpiresByType text/javascript "access plus 2 hours"
ExpiresByType text/xml "access plus 2 hours"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/ico "access plus 1 year"
ExpiresByType audio/mpeg "access plus 1 year"
ExpiresByType application/javascript "access plus 2 hours"
ExpiresByType text/js "access plus 2 hours"
ExpiresByType application/x-javascript "access plus 2 hours"
ExpiresByType text/x-js "access plus 2 hours"
ExpiresByType application/pdf "access plus 2 hours"
ExpiresByType application/xml "modification plus 2 hours"
ExpiresByType application/x-shockwave-flash "access plus 2 hours"
Header set Cache-Control "max-age=31536000, public"
Header set Cache-Control "max-age=2678400, public"
Header set Cache-Control "max-age=2678400, private"
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
# Set up caching on media files for 1 year (forever?)
ExpiresDefault A29030400
Header append Cache-Control "public"
# Set up caching on media files for 1 week
ExpiresDefault A604800
Header append Cache-Control "public"
# Set up 2 Hour caching on commonly updated files
ExpiresDefault A7200
Header append Cache-Control "proxy-revalidate"
# Force no caching for dynamic files
ExpiresActive Off
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
Header set Cache-Control "private, must-revalidate"
thanks guys for the feedback
@ stevenroddis
mod_gzip is intended for Apache server on a local machine or if I have a control of the server
but in my case , I uploaded the script on a hosted website , that uses Linux , so my best shot is using .htscript commands
@ justin
gzip compression is done automatically , that is the server compresses the css & js files and the browser extracts them , so its regularly updated
and you can set an expiration date of the zipped files in case you cached them
@ Nullig
I'll try your code, hope it works
http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/
If you have the modules installed on the server already you can use .htaccess :)
thanks steven
I checked the link, and whenever I add any code to the .htscript , I get a server error !!!
after searching , I found this code
<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
I added it to the index.php, and it worked , the website is much more faster
Cool!
I don't think that'll gzip the JavaScript though :(
Actually you should just be able to ob_start("ob_gzhandler"); as from memory gzhandler checks if the browser supports gzip or not.
I add into SI .htaccess the following:
SetOutputFilter DEFLATE
I tested the page here:
http://www.gidnetwork.com/tools/gzip-test.php
The result is a 75.4% Compression.
My old problem (that I never understood when large font and buttons appear on the screen) is gone.
Thank you for the suggestion.
Jos
thanks guys
when you find the best .htaccess option for gzip & caching please commit it into svn
cheers
justin
Hi
I gzip in index.php posted above works for me, but I cannot tell straight away by just loading the pages. Howeevr the gzip testing utility link posted above does mention that my installation is using gzip and compression is around 75% as well. However gzip can also be enabled from php.ini as well:
1. enable gzip from index.php - add the following php code at the start of the index.php file:
<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
2. enable gzip from php.ini - add the following variable in your php.ini file:
zlib.output_compression = on
I read online that the php.ini changes are preffered over the index.php
It looks like you're new here. If you want to get involved, click one of these buttons!