UPDATE - PHP SPEEDY WP: Speedy Wordpress Plugin now available!
PHP Speedy is a script that you can install on your web server to automatically speed up the download time of your web pages. Here’s an example, from a test page:
Before PHP Speedy - 14 requests that took 4.44 seconds

After PHP Speedy - 4 requests that took 1.1 seconds

PHP Speedy automatically joined together all the appropriate files and compressed them, greatly reducing the load time of the page. Let’s see what Yahoo’s Y-Slow makes of this:
Before PHP Speedy - Grade F (44)

After PHP Speedy - Grade A (96)

Don’t take my word for it
You can have a look at the test page for yourself:
Download
You can download PHP Speedy from this link: PHP Speedy 0.4.6 download
Installation - via auto-install
In order to install PHP Speedy you should:
- Download and unzip the PHP Speedy package into its own directory
- Point your browser to the PHP Speedy directory
- Follow the installation instructions
Installation - manual
If you prefer to manually install things:
- Download and unzip the PHP Speedy package into its own directory
- Delete the index.php and install.php files
- Open config.php
- Fill in the blanks for the variables (apart from username and password). You might enter something like this:
$compress_options['document_root'] = “/home/my_site/public_html”;
$compress_options['javascript_cachedir'] = “/home/my_site/public_html/aciddrop/php_speedy/”;
$compress_options['css_cachedir'] = “/home/my_site/public_html/aciddrop/php_speedy/”;
$compress_options['minify']['javascript'] = “1″;
etc - Make sure the directories you specified for the cachedirs are writable
- For the GZIP, minify and expires options 1 is on and 0 is off
- Open the php file that controls the output of HTML that you will be compressing. This might be something like index.php. Include the php_speedy.php file at the very top, i.e like this:
require(’/home/my_site/public_html/aciddrop/php_speedy/php_speedy.php’); - Add this code at the very bottom $compressor->finish();
Stay up-to-date
I have some more killer features planned for PHP Speedy, so make sure you subscribe to my RSS feed to stay up-to-date.
Donate
If you found the script useful and it saved you some time, please consider donating. Any amount is fine.


















would this work on a wordpress installation?
Yes this works fine on WordPress. The script gives you instructions on how to set it up with WordPress on Stage 3 of the install process.
I am working on a Wordpress plugin though if you can wait a while longer.
This looks badass and could really speed up some of my sites. I’m gonna check it out. Thanks!
Ok Larry, let me know how you get on and if you have any problems just shout.
Any chance you could write up an install procedure for those of us who can’t or don’t care to use the automagic installer?
anonymisto, I have added some manual install instructions above.
alright, I’ll try and hold off until a wordpress plugin - that would be fantastic!
very high memory usage!!! gz_compress cache content is better than ob_start (”ob_gzhandler”);
thanks vfgs, I’ll have a look at gz_compress.
OK - I’m sure I’m missing something, but when I inserted this in my WordPress install per the automated instructions, the end result was that my CSS was disabled. Does something in my CSS need to be adjusted to take advantage of this?
And I didn’t have my php_speedy in the wordpress directory. Problem solved.
All PHP files for public distribution should start their code with <?php, not <?. Short tags requires that PHP was compiled with it (–enable-short-tags) and as such many installations do not support it. Short tags get in the way of serving XML files and as such I have them disabled.
Leon, This is looking good really! I did check the web page load time in Fire-Bug, and I see improvement in the speed of web page loading.
You would make this job easier for a lot of guys if you could come up with a plugin for WordPress and other platforms as well.
I am testing it on one of my blogs now and would let you know If I face any issues!
Good Luck ….Great Job!
Not works for me!
I’ve done all the steps described above,
but i just have a blank page on my site
I`m using .htaccess to rewrite links and emulate folders. Will this work?
a wordpress plugin would be brilliant!
I’m trying this out right now on my blog. I inserted the code before the get_header() function, but my get_footer() function is in my sidebar.php file and not my index.php file. I inserted the other code after the get_footer() function in my sidebar.php file. I don’t know if that makes any difference or not, but when I try running my page and I look at the source code, I am getting the error “Fatal Error: Call to a member function finish() on a non-object in /home/jjjunk/public_html/wp-content/themes/leia-en/sidebar.php on line 114.” Anyway to get that fixed?
I get the message “Rendering of template admin_container.php failed” when trying to use auto installer. I am using Wordpress 2.3. Any ideas for a fix? I could try the manual install but would like to see the auto install work.
what about AJAX ?
and what about complex php script, that can exit() with header(”Location: ….”); for example in middle part of PHP script ?
Do I should control this myself ?
Hey man, just foolin’ around with tonight, immediately got this error trying the auto install:
Rendering of template admin_container.php failed
Hi, there is a problem for me: the script creates _cmp_* files with permission 644.
Christina - glad you got it working
Jon - Thanks for the tip, I’ll change it.
Vikram - I’m working on the wordpress plugin; the installer in PHP Speedy is the basis for the options screen in Wordpress. I’ll launch the WP Plugin next week. If other CMS’s/Blogs are requested, I can look into producing a plugin for them.
Sepehr - try turning off the option for page gzipping. Then at least you will see an error message.
Carlos - yes, it should work, after all Wordpress does this. As with any site though, I do recommend testing on a non-live page first though.
Tyler - it’s coming!
Josh - try putting both commands in your index.php. Or wait will next week for the WP plugin.
Justin - thanks for letting me know, I’m going to look into this now
Alex - yes! it compresses the JavaScript that powers your Ajax. And if your script is redirecting to another location then there’s nothing to compress, so don’t add the PHP Speedy code to that page.
Jeromy - I’m looking into it, thanks for letting me know.
Peppe - what’s wrong with that?
My wordpress site uses the K2 theme, and everything seems to work right except for one thing. When I click on a tag or category, the page that it returns is completely blank. Wondering if I am doing something wrong, or if there is an incompatibility.
During the installation I keep getting “undefined index” errors, which I know is due to the security level of my host. These are usually just information messages, but after installation the example demonstration is just full of errors along with some seemingly random characters at the end. Are you able to help?
New version available for download:
0.4.2 - Added variable initialisation to prevent notice errors
- Changed CSS and JS compression to gzcompress
- Added some more checks for correct path
- Changed to full PHP tags
Please let me know how you get on!
Scott - turn off page gzipping, at least then you’ll get an error message back.
David - this should be fixed in the latest version (0.4.2). If you still get any errors please let me know.
will it work on drupal?
Hi Leon, I’ve been working on integrating PHPSpeedy with PivotX (www.pivotx.net), and so far it works very nice. A few comments:
- I really dislike Output Buffering. Maybe it’s not rational, but i just try to avoid it, because it can introduce problems later on which might be hard to track down once they start popping up. Because of this i’ve added a ‘compress’ method, so now i can do:
$html = $compressor->compress($html);
This will do almost the same as $compressor->finish(), except it takes a string as argument, and doesn’t echo it, but returns it.
This way you can integrate php speedy without the need for output buffering, as long as the application you’re adding it to doesn’t just print() it’s output as it goes.
- The issue Sepehr noted is likely not because of the gzipping, but because of the javascript minifying. I haven’t looked at the code for that thoroughly yet, but the PHP memory limit needs to be set to 32Mb minimum to handle 200kb of javascript in my case. If it runs out, it stops without giving a proper error.
Perhaps it can be modified to die more elegantly?
Anyhow, keep up the good work! This is a great script!
hi leon,
thanks for this super useful script. i managed to get it working, yet i noticed that it doesn’t include CSS files loaded as @import url(http://www…)
also, in trying to add it to my wordpress blog, i included the codes in the my_theme/index.php file, but got this error. I’m using wordpress2.3 on a php5/mysql5 server
Fatal error: Uncaught exception ‘JSMinException’ with message ‘Unterminated string literal.’ in /var/www/pixeline/public_html/_lib/php_speedy/libs/php/jsmin.php:94 Stack trace: #0 /var/www/pixeline/public_html/_lib/php_speedy/libs/php/jsmin.php(178): JSMin->action(2) #1 /var/www/pixeline/public_html/_lib/php_speedy/libs/php/jsmin.php(64): JSMin->jsmin() #2 /var/www/pixeline/public_html/_lib/php_speedy/controller/compressor.php(353): JSMin::minify(’/*??Cross-Brows…’) #3 /var/www/pixeline/public_html/_lib/php_speedy/controller/compressor.php(132): compressor->do_compress(Array, ‘javascript(Array, ‘javascript’) #5 /var/www/pixeline/public_html/blog/wp-content/themes/pixeline/index.php(67): compressor->finish() #6 /var/www/pixeline/public_html/blog/wp-includes/template-loader.php(20): include(’/var/www/pixeli…’) #7 /var/www/pixeline/public_html/blog/wp-blog-header.php(21): require_once(’/var/www/pixeli…’) #8 in /var/www/pixeline/public_html/_lib/php_speedy/libs/php/jsmin.php on line 94
cool idea !
Hi Leon,
I’m pretty excited about using this for my SugarCRM installation. Each page request uses about 30-40 js and css files becuase it was designed to be very modular and customizable. The performace cost is obvious, so I was glad to run into php_speedy.
I got it installed ok, and the test page works fine, but it doesn’t actually seem to be doing anything for my sugar install. All requests go through my index.php where I added the require php_speedy, and $compressor-finish() lines.
I added some debug output to the finish() function, and tried to inspect the data in $this->content, but its blank. My debug statement appears at the end of my page, and nothing was echoed after that.
I’m not sure how php_speedy is supposed to intercept the content to manipulate it and then finally echo it in finish(), but it doesn’t seem to work the way my sugar pages are writing thier output.
So it seems logical that php_speedy isn’t doing anything in my case becuase it hasn’t captured any of the output of my php pages, so it has no text to operate on.
Any ideas?
I was wondering how to install this for pixelpost (photoblogging software)? It works on the same principle as wordpress (i.e. there is an index.php file and a template file). My problem is with where to put the include and compress statements. The end of pixelpost’s file basically echoes the template, so where is phpspeedy supposed to go?
Just tried installing on 0.4.2 on a Dreamhost server. Nothing works at all, even the test page.
oww Nice!
this work on a wordpress installation?
Odd issue occurring for me…
When I initially load the page all of the AJAX like javascript works fine. When I reload or navigate to another page (such as from product.php?id=1 to product.php?id=2) the javascript stops working (ie. lightbox, ajax load, etc.)
Any thoughts?
It seems my previous problem with “Rendering of template admin_container.php failed” during auto installation was due to an incomplete ftp transfer up to my host. It is now fixed.
I am now experiencing the same problem as Scott. I get a blank page when clicking on a category or a link to the actual article. I turned of gzipping (using 0.4.2) for the page and it then worked correctly. I would like to be able to get the benefit of gzipped pages. I am using Silhouette theme in
Wordpress 2.3. Any thoughts?
Hi Leon, this looks interesting and I’m trying to implement it in Drupal at the moment. I’ve installed it in the template, using your test page as a guide, so that the include statement is at the top (and is called on every page view) and the compressor command is at the bottom of the template. The paths are all set up and correct in the config file. The result is that a single php file is created in the cache folder containing only the minified JS for the site. This JS is broken and no javascript appears to work in the Drupal site because of this. The CSS isn’t cached (according to yslow) or compressed.
This could make an excellent edition to Drupal’s built in caching, any chance of getting it working with Drupal? Let me know if you’d like more help with the Drupal side of things.
Jonathan - I haven't tested it on Drupal. I'll give it a go when I have a moment.
Bob - Good idea, I've added that in. Thanks for the heads up on the JavaScript minification. I'll lower my memory limit and investigate.
Alexandre - no it doesn't work with import@ yet, thanks for the suggestion. The error looks like it could be a problem with your JavaScript. Try running it through JSLint to see if it has any problems: http://www.jslint.com/
Ajith - trying turning off page gzipping and see if you get an error message. Otherwise, you could try increasing your PHP memory limit.
Pavel - PHP Speedy should be included right at the very top, and at the very bottom after the file echoes the template. It works by capturing the output buffer so it's supposed to be called after the final echo.
Peter - try turning off page gzipping and see if you get an error message.
hell-world - yes.
Corey - have a look at the source code of the page where it's working (View | Source in your browser) and also of the pages where it's not working. Is the JavaScipt being included differently?
Justin - I've added in some extra checks for the gzipping. Please try it again now.
Tanc - I've added in new function to the compressor class at Bob's suggestion (above). This means that instead of running $compressor->finish() you can compress any output directly with $compressor-compress($your_content). So for Drupal you could run something like this at the end of index.php:
Great to see you working on a WP plugin
I gave it a try too but as I'm not that good in PHP and lack the time to wrap my head around it, the project has stopped completely
Before releasing the plugin, could you double-check for compatibility with plugins like WP-Cache? Might or might not create complications.
??? Does it works ... I'm looking at the final html files in cache and ... is the same and testing it with firebug... and gess what... is the same, please could you tell me what to do??
Leon - I did turn off all the gzipping in the config, and I did not see any error messages. I think I'll test this compress on-the-fly feature you just added next.
Peter - I'm running my stuff on Dreamhost as well. The test page works fine. I'm just having trouble with my specific app. I am using php5 though. IIRC, Dreahost uses php4 by default. I compiled my own php5 for some compatibility issues I had with some of my software. Perhaps that might produce different results.
Hi, in my blog it does't work.. i've install php spedy, and i've try many combination of configuration but it work only with all config on "no" ...
If i try to compress java for example, the slide bar don't work. The same thing append with a css compression...
If i try all configuration option on "yes" the page give a lot of time to charge and at the end appear the page error 500 ...
I can't enable JavaScript compression.
http://pyr2.nmsu.edu/~cwyatt/map/
The _cmp_javascript_ file exists on the server. However when I try to get it through a web browser, it returns a blank file. The CSS compression works fine and the settings for CSS and Javascript compression are the same. Any ideas?
Hi Leon, I installed this on my Wordpress blog. I think some thing is not right. On the test page I cannot slide the horizontal slider and all CSS text is same black color on white background. I used all default options. Can you help me with this?
Regards.
Redemption - I've had a quick look at your blog, and I think it may have a problem with one of the plugins:
The script couldn't compress JS that in outputted by a PHP file. I have added in a fix for this, so please try again now.
Curtis - I have had a look through my code and managed to find a bug that might be causing your problem. Please try again with the latest version (0.4.4). If that doesn't work, open up the _cmp_javascript file in a text editor - what does it contain?
zParacha - please try the lastest version (0.4.4). If it still doesn't work on the test page, what do you see when you view the source of the test page?
@Hi, there is a problem for me: the script creates _cmp_* files with permission 644. @You: Peppe - what’s wrong with that?
With permission 644 to this files, my host can't read the files.
If i change to 755 all works fine, but then the script re-writes.
I've try with new release in my site and the page full loading but there isn't any change with yslow and also the page give error with css. I've made ths screeshot with all option active http://img228.imageshack.us/img228/5079/90000292dr4.jpg
..i've test with different option but the result never change.
There is problem with permission? my actual permission are directory 750, files 640
Hi Leon,
I installed it in my Wordpress blog. It works good, apart from the fact that it outputs the string "null" on the top of the site (and of the test page).
Any idea how can I remote the string?
I used version 0.4.4
Hi Leon,
I'm testing php-speed in groupoffice in a windows environment. I find some problem because my application is not running directly under the main Apache document_root, but it is defined as alias in the httpd.conf file. I add some additional information in the config file to specify the correct path, and it work properly !
But I find out a bug ... once css and js files are cached there is a problem when the script tries to remove the [script] tags
in compressor.php, if the $array_script contains a [script] tag without SRC tag you remove the key from array
//Make sure src element present
foreach($script_array AS $key=>$value) {
if(!strstr($value,$options['src'])) {
unset($script_array[$key]);
}
}
the you call a _remove_scripts funcition that fails if some key in $script_array is missing.
function _remove_scripts($script_array,$source) {
foreach($script_array AS $key=>$value) {
if($key == count($script_array)-1) { //Remove script
$source = str_replace($value,"@@marker@@",$source);
} else {
$source = str_replace($value,"",$source);
}
}
return $source;
}
you must change this function in this way:
function _remove_scripts($script_array,$source) {
foreach($script_array AS $key=>$value) {
$source = str_replace("@@marker@@", "",$source);
$source = str_replace($value,"@@marker@@",$source);
}
return $source;
}
Dear Leon,
I tried your last version (0.4.5), and the test page is'nt works on my page (no css and javascript).
My settings:
Document root: /nfs/extra/b/be/begreeny/wwwroot (detected: /nfs/extra/b/be/begreeny// )
cache dirs: /nfs/extra/b/be/begreeny/wwwroot/t/php_speedy/
The requests in the test page e.g. a javascript file:
The good url is:
Thanks for your hard work.
Peppe - the latest version (0.4.5) sets the permissions to 755.
Redemption - please try with the latest version
Claudio - please try with the latest version
Massimo - thanks for the tip, I'll have a look at your fix.
Begreeny - are the _cmp_ files created in /nfs/extra/b/be/begreeny/wwwroot/t/php_speedy/ ?
Yes:
In /nfs/extra/b/be/begreeny/wwwroot/t/php_speedy/ there are:
_cmp_cssalternatehandheld_78216aec20bd80b77d5428868ee0b006.php
_cmp_cssalternateprint_965a7f83b73a7ecb5df94a5de2db605f.php
_cmp_cssstylesheet_86ad7f58e44312e03da62ddd5d93e4cc.php
_cmp_cssstylesheetprint_17380c3440fce66100eb1c2fecca4ce5.php
_cmp_javascript_36004c76bc8358d9aba7848d70c44f80.php
Begreeny - Perhaps you could email me the output from print_r($_SERVER) and your PHP Speedy config.php and I'll try to figure it out. leon at aciddrop.com. Thanks!
@ Leon :
I've try this new version but it does't work... same thing 0.4.4
@ Leon:
I have installed the latest version (0.4.5), but now it ignores my Javascript completely and doessn't compress it at all. All it does is the CSS. Also, I think it would be better if all the compression was put into /php_speedy/cache instead of directly in the php_speedy folder.
Curtis - there is a problem with PHP files that output JavaScript: PHP Speedy can't get the file contents from the server because it contains PHP. It would have to get the contents from a HTTP connection, but that's for another version (maybe). For the moment, only .js JavaScipt files containing JS code are supported.
Curtis - oh, and you can set the cache directory yourself in the installer.
Redemption: what are the contents of your HEAD before and after using PHP Speedy?
@ Leon:
Cache directory: Yeah, I just thought doing it as a default might be a good idea.
Ok. I didn't realize fopen or file_get_contents parsed the php before returning the contents of the file. (I didn't look at the code but I'm assuming that is what is going on.) I will wait for the day when it is possible :).
Now the css work fine(my mistake) but the result never change 21...
this is Head
Before
<!-- ****STATISTICHE*** -->
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
var pageTracker = _gat._getTracker("UA-2166967-1");
pageTracker._initData();
pageTracker._trackPageview();
<!-- ****FINE STATISTICHE*** -->
<!-- Added By Democracy Plugin. Version 2.0.1 -->
<!-- Start Of Script Generated By WP-PageNavi 2.20 -->
<!-- End Of Script Generated By WP-PageNavi 2.20 -->
<!-- Added by Quoter plugin v1.1 -->
.commentlist blockquote cite { /* Fix for Kubrik theme */
display: inline;
}
.recentcomments a{display:inline !important;padding: 0 !important;margin: 0 !important;}
after
<!-- ****STATISTICHE*** -->
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
var pageTracker = _gat._getTracker("UA-2166967-1");
pageTracker._initData();
pageTracker._trackPageview();
<!-- ****FINE STATISTICHE*** -->
<!-- Added By Democracy Plugin. Version 2.0.1 -->
<!-- Start Of Script Generated By WP-PageNavi 2.20 -->
<!-- End Of Script Generated By WP-PageNavi 2.20 -->
<!-- Added by Quoter plugin v1.1 -->
.commentlist blockquote cite { /* Fix for Kubrik theme */
display: inline;
}
.recentcomments a{display:inline !important;padding: 0 !important;margin: 0 !important;}
I've made a mistake, css work fine with ie7 but with firefox no..
this is is the code after php-spedey active.
<!-- ****STATISTICHE*** -->
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
var pageTracker = _gat._getTracker("UA-2166967-1");
pageTracker._initData();
pageTracker._trackPageview();
<!-- ****FINE STATISTICHE*** -->
<!-- Added By Democracy Plugin. Version 2.0.1 -->
<!-- Start Of Script Generated By WP-PageNavi 2.20 -->
<!-- End Of Script Generated By WP-PageNavi 2.20 -->
<!-- Added by Quoter plugin v1.1 -->
.commentlist blockquote cite { /* Fix for Kubrik theme */
display: inline;
}
.recentcomments a{display:inline !important;padding: 0 !important;margin: 0 !important;}
(I've post the code)
Does this script work with HTML?
How would you tackle the problem of different sets of javascript for different pages within one site?
For example a form that requires 1 set of javascript functions for Fruit Sales and another form with a different javascript set for Vegetable Sales.
When the fruit page is requested, the fruit javascript library is compressed and cached. Then if the vegetable page is requested the vegetable library is compressed and overwrites the cached fruit library.
When multiple users are requesting the different pages simultaneously the files are just being constantly rewritten.
I'm curious, does this plug in permit robot/crawler to read all the HTML text? Because I tried and installed the script and when I check my blog with keyword analyzer on the web, it seems like the analyzer can't read what inside my HTML. Is it because it's compressed? Where does this compressed HTML being decompressed? At the client side?
what about "smart ass" JS code, that load another JS parts, imgs , etc ?
hi, i had a problem with the name of the cached css file. it contained %2c, a comma. however, the browser wanted it to be loaded as %252c (encoding the percent sign as %25).
anyway, to resolve the issue, i edited line 340 of compressor.php to the following:
$cache_file = '_cmp_' . preg_replace('/[^a-zA-z0-9]/', '', $options['save_name']) . '_' . md5(implode("_",$script_array).$datestring.implode("_",$options));
it just uses a regexp to strip out non-alphanumeric characters.
the script works well now for css, but for some reason isn't minifying js yet...
good work though
andy
Alex - no I'm afraid that's no supported.
andy - thanks for the fix. The JS minify only works on PHP5+ as the jsmin library it uses requires that. Perhaps that's the problem.
ok, the reason it wasn't minifying js was because my js is included right at the end of the body. so i modified get_script_array so it didn't call get_head, and it worked (well, actually, the combined js doesn't work, but the compressor is working at least).
thanks again
OK, I see. Well it's really intended for JS that's all in the same location in the order of the page, as it combines all the scripts into the same file. If changing get_head to get_entire_page works for you though, well, go for it
Try running the JS through JSLint to check for any problems.
good work leon.
i was just thinking about how the files are cached. it's not very efficient. a better way would be as follows:
if it's combining and compressing js files, the class could stat each file being combined to get the last modified time. these could then be used as the filename for the cached version (separated by underscores or themselves md5-ed).
doing it this way means it would be faster to find out if there is already a cached version of the javascripts, without having to minify them all and use an md5.
thx tom
Seems like your version 0.4.5 is working better on my blog. I have all the options enabled and everything loads fine. My blog loads faster too, but some things don't seem to be working. It's at least initially loading at about 5 sec instead of the 10 sec it would normally take. I think most of my problem is that some of the javascript isn't in the head.
Thanks for making php_speedy. I'll be looking forward to more updates.
I'm about to install it. but is there anyway to disable it or like uninstall it?
would php_speedy still affect my blog's load time if i had all the options turned off?
Hi, i have a problen to use the program in wordpress.
After install this is the output:
Warning: Invalid argument supplied for foreach() in /home/jujol0/public_html/php_speedy/controller/compressor.php on line 556
Warning: Invalid argument supplied for foreach() in /home/jujol0/public_html/php_speedy/controller/compressor.php on line 563
Warning: implode() [function.implode]: Bad arguments. in /home/jujol0/public_html/php_speedy/controller/compressor.php on line 344
Warning: Invalid argument supplied for foreach() in /home/jujol0/public_html/php_speedy/controller/compressor.php on line 556
Warning: Invalid argument supplied for foreach() in /home/jujol0/public_html/php_speedy/controller/compressor.php on line 563
Warning: Cannot modify header information - headers already sent by (output started at /home/jujol0/public_html/php_speedy/controller/compressor.php:556) in /home/jujol0/public_html/php_speedy/controller/compressor.php on line 315
Can you help me to solve the problem?
Is there an uninstall procedure? I have removed the cache, removed the files and I'm still getting cached data.
i've made greater savings by packing js instead of minifying it.
here's a version of dean edwards' packer in php:
http://joliclic.free.fr/php/javascript-packer/en/
it's easy to switch from minifying to packing
...and also adding the following to minify_text makes even smaller css files:
// strip spaces after certain characters
$txt = preg_replace('/\s*(,|;|:|{|})\s/', '$1', $txt);
Andy, how did you get Dean's packer in? and which file did you add that text to?
I keep getting the class not found error...no idea why. Test page works fine...
tom - that's exactly how it works! The md5 in the filenames in the last modified time of each file together. If the md5 is the same as the current files, no more work is done by the script.
agung - to uninstall just delete the php_speedy directory and remove the code you added to your script(s). If all options are off it wouldn't do anything.
jujol - please try the lastest version 0.4.6. Does the test page work OK? What do you have in the HEAD part of your HTML?
Cliff - remove the code that you added to your script. Make sure the page isn't cached.
andy - The reason I avoided packer is because the code requirements are stricter, but thanks for the info.
Jeremy - make sure you are including the compressor class with the correct path. The lastest version (0.4.6) may help too.
Redemption - try running the JavaScript through JSLint:
http://www.jslint.com/
Well, I can get the page to stop displaying the error. But it doesn't display anything at all now. Just a blank page. 0.4.1 worked with the same setup, but 0.4.5 and 0.4.6 have not worked.
Dear Leon,
Thanks for your fixes. The 0.4.6 version works perfetly on my blog!
http://jeremy.tymes.name/ is my example.
It returns 3KB of something, but it isn't being outputted the right way (not at all). I use the installer to do everything, and like I said 0.4.1 worked.
Jeremy - what does the HEAD of the document contain?
Gzip options for javascript and CSS is not working for me. Any idea why ?
The test page dont show any CSS nor the main page. Gzip page is working.
Thanks for the help.
well done leon, you're one step ahead of me!
daniel, to use the packer instead, i put class.JavaScriptPacker.php into libs/php, then search for:
$contents = $this->jsmin->minify($contents);
and replace it with:
$path = dirname(__FILE__);
require_once($path.'/../libs/php/class.JavaScriptPacker.php');
$packer = new JavaScriptPacker($contents, 'Normal', true, false);
$contents = $packer->pack();
in controller/compressor.php
good luck
http://jeremy.tymes.name/head.txt
This isn't the original site I was running it on, but I tried it on this site and it still didn't work...so here's the header of that...I have inline Javascript and CSS because I was lazy when I made the site...but I would think that it'd still work.
Hi I have a big problem of cache
I have a script to upload images and change the images that is working I see in the the hosting the images are ok, but in EI or FireFox I have the same old image, in the configuration file I'm using:
## Minify options
$compress_options['minify']['javascript'] = "1";
$compress_options['minify']['page'] = "0";
$compress_options['minify']['css'] = "1";
## Gzip options
$compress_options['gzip']['javascript'] = "1";
$compress_options['gzip']['page'] = "0";
$compress_options['gzip']['css'] = "1";
But I can't see the images....
Jeremy - actually, the latest version doesn't work with inline JavaScript and CSS. It was causing quite a few problems, so I changed the script to only work with CSS and JS with .css and .js extensions. Just create separate files and all should be OK again.
Licantropo - are you talking about CSS background images? What does the source of the page with the images look like before and after PHP Speedy?
leon, i've found another bug. if you use $compressor->ignore(), files containing the given string are ignored, but the rest of the files aren't combined and included. it can be fixed by modifying _remove_scripts as below:
function _remove_scripts($script_array,$source) {
$maxKey = array_pop(array_keys($script_array));
foreach($script_array AS $key=>$value) {
if($key == $maxKey) { //Remove script
$source = str_replace($value['location'],"@@marker@@",$source);
} else {
$source = str_replace($value['location'],"",$source);
}
}
return $source;
}
I love php speedy. It's one of the most useful piecese of code I have seen and used.
I found a bug in css processing. When I'm using YUI libraries (http://developer.yahoo.com/yui/) it messes up some background url paths.
When I'm using datatables and buttons libs in the same page it changes urls of backgrounds.
good example:
.yui-skin-sam .yui-dt-table th {
background:transparent url(/path/to/assets/skins/sam/sprite.png) repeat-x scroll 0pt;
}
I get something like:
.yui-skin-sam .yui-dt-table th {
background:transparent url(/path/to/path/to/path/to/path/to../../../../../sprite.png) repeat-x scroll 0pt;
}
andy and Matej - many thanks for the bug reports! I will test them and fix as soon as I have a moment.
I'm using Joomla 1.0.13 and whenever I login on the frontend as a user I'm getting
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
--------------------------------------------------------------------------------
Apache/1.3.33 Server at massageinmytown.net Port 80
Whenever I disable the mambot the problem goes away.
leon
i run wordpress 2.3.3
i installed speedy
when i "view" the site i get:
1람����A�6�D���vk�*��e�)v �M���7D�ȸ\�����7���Š�a`Ճa�H"Ƥj��й�QUӽ�Z���'��hlUU3��(S�^3-��(����jz�/��D�GҒ���ɛ�5y�h�M.��rl;��'�'�]��G�"��0�i��K������Yu��o�5��x���22 _�yރu�2+O���E���^ߨ�~������K[�Tk�՚?W�ύY��ӧ�y����k�N��\AQ�& ��Y���t\pw��ʌ�k,�̦��+Sݭ�(����b�?GF'^� ��?��Ŀm�JF��q���y���~���9��s��6���&�-8����9�t��R숊�bZqe wt�"�k�t���C�n���Y���^��.zI
please help urgently
Charles - edit config.php in the speedy directory and turn off page gzipping. The page should now display, and you'll probably get an error message that you can now fix.
Hello Leon, I have a simply question about this "jewel"
Seo is compromised or not change, after install Php Speedy?
Thanks for your work!
Massimo
When you install on the demo page what are the calls to these 2 files that are not incuded in the release ?
And my demo test page only ranked Performance Grade: B (83) is that right I throught it would make it to a A
A 1. Make fewer HTTP requests
F 2. Use a CDN
F 3. Add an Expires header
A 4. Gzip components
A 5. Put CSS at the top
A 6. Put JS at the bottom
A 7. Avoid CSS expressions
n/a 8. Make JS and CSS external
A 9. Reduce DNS lookups
A 10. Minify JS
A 11. Avoid redirects
A 12. Remove duplicate scripts
F 13. Configure ETags
But I have eveything turned on so not sure why in the demo images it scores A
Great work! I'm wondering how this might be used on a regular, non-WordPress site. Is that possible even though all my files are html and not php? Or is this only for WordPress?
Thanks.
when is the wordpress plugin coming
hi there,
i'm getting the following errors in joomla
i have the latest version from speedy. my header is
Warning: Invalid argument supplied for foreach() in /php_speedy/controller/compressor.php on line 556
Warning: Invalid argument supplied for foreach() in php_speedy/controller/compressor.php on line 563
Warning: implode() [function.implode]: Bad arguments. in php_speedy/controller/compressor.php on line 344
Warning: Invalid argument supplied for foreach() in php_speedy/controller/compressor.php on line 556
Warning: Invalid argument supplied for foreach() in php_speedy/controller/compressor.php on line 563
Here's a question.. I installed the software, and I'm getting erratic results. Works like a charm on my home page (wordpress 2.0.11)
However, your installation notes say:
"Now should should add the PHP Speedy code to your own PHP page. This is made a lot easier if you have one PHP file that serves every page in your site. In a Wordpress 2.3 blog, for example, this would be the index.php file for your theme. Because index.php is accessed for every page, we just have to modify that file. If you have different PHP files serving different pages, then you will need to modify each of those pages."
I modified that extra php pages as you indicated (such as archives.php, category.php, etc.), but those pages that are served very poorly.
When I go to those pages, I get an "ill" looking pages, almost straight HTML old school style.. it's missing something (not sure what.. style.css, or whatever)
Any clue what to do? Should I clear any caches on the server (such as WP-cache) or reboot or restart? Http & mysql, etc?
Please advise
I should add a couple more things..
I have the following employed on the server as well:
- eAccelerator http cache
- Varnish HTTP proxy (which splits logged in users to port 80, non-logged in users to port 81)
Also on the wordpress installation are wp-cache and plugin-output-cache.
However, I don't think those are the problems. Using PHP Speedy, it seems only my CSS isn't working. When using firbug, it doesn't find any style.css for my site.
Your thoughts?
Ok, I have yet a third post here.
I got it semi "working" by not messing with gzip or minify on the CSS.
However, checking my YSlow, it said many .js files were not minified... making me think that the way my theme is designed, that there may be an issue.
For instance, my index file just calls the various parts of the site, such as this very simplified example...
My question should be then, should I add the PHP Speedy code to each and every component on my site? Such as the sidebar, post, page, etc?
Because the index.php file in particular, has no Javascript calls in it, only the internal components of the site do, such as the post.php and sidebars...
Please advise, and it's great to see tools like this around!
Thanks!
Do you have a version which does not require you to use the install wizard? I would like the php files to reside outside of my html root and would like to install it manually.
How come you are changing the $_SERVER['DOCUMENT_ROOT'] (line 37 of compressor.php)? This is set by the server, why don't you just the document root instead of making users set it in the config.
Also the JS and CSS cache paths would be nice to not have to be full paths. You could just tack them on to the end of $_SERVER['DOCUMENT_ROOT'] to allow for easier maintenance and flexibility.
Also I am seeing these errors:
STRICT : XXX/php_speedy/jsmin.php : LINE 167
Redefining already defined constructor for class JSMin
NOTICE : XXX/php_speedy/compressor.php : LINE 277
Undefined index: HTTP_ACCEPT_ENCODING
I am getting this error:
Fatal error: Call to a member function set_paths() on a non-object in /public/php_speedy/controller/compressor.php on line 38
Also since the page I am working on has no scripts or CSS I get a bunch of errors about foreach loops in compressor.php if I don't specify that the compressor shouldn't do scripts or CSS.
Massimo - no, it doesn't affect SEO.
John - which two files? When a page contains multiple elements, it becomes harder to hit the 90's. It's easier for my test page, because it doesn't have so many page elements. I'm working on improving PHP Speedy so it improves page elements other than JS and CSS (hint: background images).
bundle - it's not only for Wordpress, but you do need PHP I'm afraid.
PJ - I'm about 1/2 way through it. Soon, please be patient!
thomas - that looks like it's not finding any scripts in your document HEAD. What does the HEAD contain?
Perry - yes, it sounds like it's lacking the CSS. You should only need to apply it to one file. What does your document HEAD contain before and after applying Speedy?
louis - I did initially. However, the document_root can be misleading. It can be set to say, /home/user/www/, but the user can choose to serve HTML from /home/user/www/content/. By explicity setting the document_root, I wanted to help the people who were having problems with their paths. Again, for the JS and CSS cachedirs I wanted to have full fexbility, hence the full paths. Thanks for the STRICT and NOTICE errors, I will look into them.
David - strange error - is the libs/php/view.php file present? (it is included from the php_speedy.php file). Thanks for the other error report, I will fix that.
Yes, libs/php/view.php exists.
Oh and these are the foreach loop errors I had mentioned (There is also an Invalid arguments error as an added bonus):
Warning: Invalid argument supplied for foreach() in /public/php_speedy/controller/compressor.php on line 556
Warning: Invalid argument supplied for foreach() in /public/php_speedy/controller/compressor.php on line 563
Warning: implode() [function.implode]: Invalid arguments passed in /public/php_speedy/controller/compressor.php on line 344
Warning: Invalid argument supplied for foreach() in /public/php_speedy/controller/compressor.php on line 556
Warning: Invalid argument supplied for foreach() in /public/php_speedy/controller/compressor.php on line 563
Wondering what "username and password" are used for? Can these two options be left empty? If not, what are they referring to?
David C - what are the contents of the HEAD of your webpage (feel free to link to the page if you like)? How are you including PHP Speedy in your PHP?
Josef - this is to protect your PHP Speedy install directory. Otherwise some