Performance: When enable optimization for css and javascript ... site goes down instant!
| Project: | Drupal |
| Version: | 6.14 |
| Component: | other |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | duplicate |
| Issue tags: | CSS aggregation, database.mysql.inc, MySQL |
Please help!
For Missha I'm using Drupal 6.6, with the folowing webserver config:Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8b mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.5 and MySQL/4.1.22.
My theme is custom made based on Zen Theme (STARTERKIT).
In my database variables refering performance from table variable are:
- cache s:1:"1";
- cache_lifetime s:3:"300";
- page_compression s:1:"1";
- block_cache s:1:"1";
- preprocess_css s:1:"0";
- preprocess_js s:1:"0";
- clear s:17:"Clear cached data";
If I enable js and css optimization ... my website goes offline and viceversa. It's not the normal behaviour ... when it should optimize those files.
But there's more ... after activation of devel module ... site remains online, but when I enable Theme developer ... it goes offline again.
I know it's something about my theme but I can't tell what ... even I'm almost relaxed after the shock. :)

#1
You don't describe the symptom or error you get when it goes offline, but most likely (given the addition of theme developer triggers it) it's the normal old out-of-memory FAQ.
What's your php memory?
#2
My config by .htaccess (not default):
PHP memory limit: 96M
When it goes offline I can acces something like http://www.missha.ro/update.php only and not as a authenticated user.
Any other page gives me an error like it's offline and shows me nothing.
The only way to get back on tracks is to manually modify the variables in Variable table ...
Any idea?
#3
Do you mean to say your site goes into maintenance mode if you turn on js and css optimisation? Or are you just getting a blank screen?
- Arie
#4
Looks like ro_x_taz won't be posting any feedback so I'm setting this to fixed.
Feel free to reopen if you think that is wrong.
- Arie
#5
Automatically closed -- issue fixed for two weeks with no activity.
#6
I have same problem. Drupal replies zero sized page using Zen starterkit ONLY if I optimize the CSS files, NOT the JS files.
I've tried to increase PHP memory to 512M but it didn't work..
Still can't find out why..
#7
I trace the error in my Drupal 6.10, then stop in these codes :
common.inc line 1967, function drupal_load_stylesheet
<?php
if ($_optimize) {
// Perform some safe CSS optimizations.
$contents = preg_replace('<
\s*([@{}:;,]|\)\s|\s\()\s* | # Remove whitespace around separators, but keep space around parentheses.
/\*([^*\\\\]|\*(?!/))+\*/ | # Remove comments that are not CSS hacks.
[\n\r] # Remove line breaks.
>x', '\1', $contents);
}
?>
It looks like the error comes from preg_replace function. I changed these codes to :
Adds double slash in line 1971
<?php
if ($_optimize) {
// Perform some safe CSS optimizations.
$contents = preg_replace('<
\s*([@{}:;,]|\)\s|\s\()\s* | # Remove whitespace around separators, but keep space around parentheses.
// /\*([^*\\\\]|\*(?!/))+\*/ | # Remove comments that are not CSS hacks.
[\n\r] # Remove line breaks.
>x', '\1', $contents);
}
?>
ORThis code was wrong..
<!-- Adds double slash in line 1970 -->
<?php
// if ($_optimize) {
// // Perform some safe CSS optimizations.
// $contents = preg_replace('<
// // \s*([@{}:;,]|\)\s|\s\()\s* | # Remove whitespace around separators, but keep space around parentheses.
// /\*([^*\\\\]|\*(?!/))+\*/ | # Remove comments that are not CSS hacks.
// [\n\r] # Remove line breaks.
// >x', '\1', $contents);
// }
?>
And everything works fine.. Just the CSS files don't optimized perfectly.. The comments not removed..
#8
I can't reproduce this behavior. Using Drupal 6.10 and Zen Starterkit 6.x-1.0 things are working fine using CSS compression on or off.
What kind of error do you see in the webserver's log? And have you tried the steps described here http://drupal.org/node/158043 ?
- Arie
#9
I have to update this!
On another site I'm stuck with some other errors ... theme related:
Warning: MySQL server has gone away query: SELECT data, created, headers, expire, serialized FROM cache WHERE cid = 'theme_registry:isujis' in /home/isujis/public_html/includes/database.mysql.inc on line 128
Warning: MySQL server has gone away query: UPDATE cache SET data = 'a:189:{s:18:\"aggregator_wrapper\";a:7:{s:9:\"arguments\";a:1:{s:7:\"content\";N;}s:4:\"file\";s:39:\"modules/aggregator/aggregator.pages.inc\";s:8:\"template\";s:37:\"modules/aggregator/aggregator-wrapper\";s:4:\"type\";s:6:\"module\";s:10:\"theme path\";s:18:\"modules/aggregator\";s:11:\"theme paths\";a:1:{i:0;s:18:\"modules/aggregator\";}s:20:\"preprocess functions\";a:2:{i:0;s:19:\"template_preprocess\";i:1;s:38:\"template_preprocess_aggregator_wrapper\";}}s:27:\"aggregator_categorize_items\";a:7:{s:9:\"arguments\";a:1:{s:4:\"form\";N;}s:4:\"file\";s:39:\"modules/aggregator/aggregator.pages.inc\";s:4:\"type\";s:6:\"module\";s:10:\"theme path\";s:18:\"modules/aggregator\";s:8:\"function\" in /home/isujis/public_html/includes/database.mysql.inc on line 128
BTW: ?q=admin
and after
user warning: MySQL server has gone away query: UPDATE cache_update SET data = 'a:15:{s:13:\"advanced_help\";a:10:{s:5:\"title\";s:13:\"Advanced help\";s:10:\"short_name\";s:13:\"advanced_help\";s:10:\"dc:creator\";s:13:\"merlinofchaos\";s:11:\"api_version\";s:3:\"6.x\";s:17:\"recommended_major\";s:1:\"1\";s:16:\"supported_majors\";s:1:\"1\";s:13:\"default_major\";s:1:\"1\";s:14:\"project_status\";s:9:\"published\";s:4:\"link\";s:39:\"http://drupal.org/project/advanced_help\";s:8:\"releases\";a:6:{s:7:\"6.x-1.1\";a:12:{s:4:\"name\";s:21:\"advanced_help 6.x-1.1\";s:7:\"version\";s:7:\"6.x-1.1\";s:3:\"tag\";s:13:\"DRUPAL-6--1-1\";s:13:\"version_major\";s:1:\"1\";s:13:\"version_patch\";s:1:\"1\";s:6:\"status\";s:9:\"published\";s:12:\"release_link\";s:29:\"http://drupal.org/node/322831\";s:13:\"download_link\";s:65:\"http://ftp.drupal.org/files/projects/advanced_help-6.x-1.1.tar.gz\";s:4:\"date\";s:10:\"1224280802\";s:6:\"mdhash\";s:32:\"17061e6f638b1daafb3c4d75c0ec51b9\";s:8:\"filesize\";s:5:\"70758\";s:5:\"terms\";a:1:{s:12:\"Release type\";a:1:{i:0;s:9:\"Bug fixes\";}}}s:7:\"6.x-1.0\";a:12:{s:4:\"name\";s:21:\"advanced_help 6.x-1.0\";s:7:\"version\";s:7:\"6.x-1.0\";s:3:\"tag\";s:13:\"DRUPAL-6--1-0\";s:13:\"version_major\";s:1:\"1\";s:13:\"version_patch\" .....and continues with many many lines of errors
Until now thank you for your help! (I followed the advice with:
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
// $Id: index.php,v 1.94 2007/12/26 08:46:48 dries Exp $
...
?>
Both sites are hosted by the same provider and both have this problem. Cpanel doesn't show me any troubles with the hardware or resources (max 30% load). Logs doesn't tell me anything ... useful.
Any partial solution or suggestion for troubleshouting?
#10
I duplicate the error on wamp localhost with Drupal 6, but I have a massive amount of modules installed also, using Zen theme. When optimizing CSS is set to true then site is dead. Followed the method above and resolved the issue.
I was led to this error by way of using panels not displaying style in IE. There was a fix to simply make 'optimize CSS' as true. When selecting this it produced the error.
#11
Oddly enough I'm getting a similar issue, except only for CSS Optimization, and not JS Optimization.
I've copied a production site to my local environment to do some debugging. I've cleared both the site and my browser cache, as well as the cache* tables inside the database.
I'm currently using two seperate themes for the front-end and the back-end. For some reason when I access the front-end, I either receive a "Connection Interrupted" message, or the page tries to navigate to www.localhost.com/*.
Nothing shows up in the error logs (including server logs).
If I change the front-end theme to Garland, everything works fine - so it's to do with my theme. However, the Production site is working with CSS Optimization enabled.
The fix above involving preg_replace works for me as well, but I'm not sure what caused this issue in the first place (given that I should be working with a mirror of Production locally, and CSS Optimization is working on Production).
#12
Oddly enough, I never found in all the posts on css opimization issues a suggestion to run all css files through http://jigsaw.w3.org/css-validator/ I had a problem similar to many of the posts on the topic "css optimization breaks the theme" and tracked it down to a misplaced brace in one of the style sheets.
Hope this helps someone with a css optimization issue.
#13
My solution was the same as comment #12. The error was in one of my Zen css files.
Here's the line you might want to check. I used Zen to create my own theme, so I had copied layout.css and renamed it to my_layout.css. Look for these lines...
/* Alternatively, the skip-to-nav link can be completely hidden until a user tabs
to the link. Un-comment the following CSS to use this technique. */
----------- More lines - Keep scrolling down ----
#skip-to-nav a:active, #skip-to-nav a:focus
{
position: static;
width: auto;
height: auto;
}
*/
I had removed the comment line at the top and left the comment line at the bottom of that section. Check that line in case you did the same thing.
Ashford
#14
I think the problem is when you have css aggregation enabled and then you change the default theme - for me that crashes apache on my local webserver.
On the other hand if I turn off the css aggregation, changing the default theme succeeds without problem.
(yes, I have a ton of other modules enabled too.)
#15
I have this same problem using Drupal 6.13, Zen 6.x-1.0. My remote server is fine with CSS enabled. Using XAMP locally on two different machines runs great, but as soon as CSS Optimization is turned on, the site homepage returns a "connection reset" error message. Admin works fine with CSS Optimize turned on. Changing the site theme to Minelli or the Zen starter kit, and CSS Optimize then works fine. (My theme is based on Zen StarterKit.) I have searched and replaced every instance of single quotes in comments to no avail. Also, my homepage is valid CSS according to FireFox web developer.
Anyone have any tips on how to find out what the problem is?
Thanks!
#16
I'm having the same issue, also using a Zen subtheme. I took out all apostrophes in the comments, checked for parsing errors using W3C Validator, etc. and my site still crashed when I turned on CSS Optimizer. The Javascript Optimizer works fine, it's only the CSS that does it (says "Connection Reset", not the Whitescreen of Death.)
I tried the suggestion in comment #7 and it seems to have worked, now it only loads 4 stylesheets (down from 20-something) -- thanks!
#17
I was having the same exact problem.
I'm using Zen as well.
After noticing WYSIWYG + TinyMCE wouldn't display at all in IE6, I turned on CSS optimization and blammm... instant Apache crash.
Apache error.log:
[Mon Aug 24 09:37:49 2009] [notice] Parent: child process exited with status 128 -- Restarting.
One tip-off was that I have the admin module installed and I could get to any admin page, however the minute I'd hit anywhere else on the site... crash!
I'm guessing PHP might have a bug in "preg_replace". I followed comment #7 and commented out the line in common.inc and everything started working fine.
Thanks
-- Jason
#18
Can confirm #7 worked for me, under Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9
#19
I have the same problem, however if i make changes from #7 wont this be altering core?
If this is a bug for core wouldn't this be better to be added for update?
#20
Edit: Well no, just experiencing the same issue, what I was suggesting is wrong.
#21
While option #7 is a small edit if I update core and it over writes this file on the next security update it would soon come back, anyway if it was the cause why hasn't it come up on any of the other sites I have created over the past year. Does anyone know if this was an alteration for files in 6.13.
I am happy to try anything see if it makes any difference but before i start pulling apart core on my site I think I would like to have a better understanding of what the issue is.
#22
Has anyone try to remove comments from Zen's CSS files? After I remove comments from Zen's CSS files, the WSOD never exists, even if using the original common.inc file.
#23
Is this related to #543892: Win XAMPP 1.7.2 Regex PHP Bug - Optimize css & long css comments fails?
http://drupal.org/node/543892#comment-2069668
#24
After almost 5 hours of debugging I can across this post... I confirm that the fix at #7 works
This is a serious bug and "normal" users will be left with a dead site I'm afraid.
The problem is not fixed in D6.14 so we still need to hack
#25
If the maintainer needs more info I will be happy to give a case where its reproducible.
This is a showstopper since I do not enable css optimization out for performance reason but to get my site working under IE.
Maybe you know that IE only accepts 30 CSS files (you can run in this issue if you have a lot of modules) so I had no choice but to turn on this feature in production.
#26
Confirmed, #7 works and from reading the thread and comparing it to my site, it suspect that it is to do with large comments in CSS files.
#27
Confirmed fix in #7
#28
A better fix that keeps the comment filtering functionality is in this thread: #444228: Optimize CSS option causes php cgi to segfault in pcre function "match".
D6 version of the patch is below. This is rolled against 6.x-dev.
Keeping the patch name in line with the original comment number on the other thread.
Update
See the linked issue above for the latest D6 patch.
#29
same problem, the following commented line in style.css makes CSS compression fail and get naked HTML:
/* @import "css/screen.css"; */patch at #7 does not help here.
The theme info file is probably a better way of including stylesheets, still adding my 2 cents to the saga ;)
#30
@marco, yours may be a different issue: #544568: CSS aggregation attempts to process @import in comment
But, for the original issue, turns out they're actively providing D6 patches in #444228: Optimize CSS option causes php cgi to segfault in pcre function "match", so marking this as a duplicate.
It would probably help get the fix committed if folks would apply that fix instead and test the patches.
#31
THIS WORKS FOR ME, 100% TNX
(but whats still the right solution?)
#32
@mattez:
The correct solution is here #444228: Optimize CSS option causes php cgi to segfault in pcre function "match". The solution in that thread is being committed to core.
#33
@gantenx
I can blow you kisses right now. Been working on my site for over a week and while doing final checks before deploying i decide to optimise css and it crashes. You are a lifesaver.