Seeing a very slow loading CSS aggregate that often takes between 6 and 30 seconds to resolve (see screenshot). It's a print stylesheet, but it's having strange effects on some page loads and especially on a bot we have setup that intermittently thinks the site is failing because of how long the CSS takes to resolve.

Network Inspector showing slow loading CSS aggregate.

Are you implementing any print stylesheet delay techniques? Any thoughts on what could be causing this?

Thanks in advance.

Comments

mikeytown2’s picture

CSS compression enabled?

iamEAP’s picture

Yup. Sane mode.

mikeytown2’s picture

Is this a one time occurrence or does it happen all the time? I personally don't use CSS compression as I've found every single library for it to be buggy. If this is happening every time then I'm guessing it might have something to do with your severs configuration as this should be a file after the first access.

iamEAP’s picture

Kind of figured. I'll look into the server configuration and report back if we find anything of note.

Regarding disabling/enabling CSS compression, can I just toggle that switch without incident or should I wait until a lower traffic period to do so?

j2b’s picture

I was trying to solve similar issues, but without AdvAgg module, which after enabling completely killed my site. Had to remove manually, and read more carefully installation. But these threads lead me to some solutions and possible problem sources:

I added configuration to DEFLATE parameter for Apache2, where it may be a reason of compression not working correctly. By the way, disabling D core page compression and enabling CSS/JS aggregation, problem appeared to disappear. Currently testing...

mikeytown2’s picture

Sounds like this issue has something to do with gzip/deflate compression. I can come up with a more complex set of .htaccess rules; ones that might work better after reading this comment. In short disable etags if mod_expires is enabled.

Disable "Generate .htaccess files in the advagg_* dirs" at admin/settings/advagg

Add this to the bottom of your .htaccess file.

# AdvAgg Rules.
<FilesMatch "^(j|cs)s_[0-9a-f]{32}_.+\.(j|cs)s(\.gz)?">
  <IfModule !mod_expires.c>
    FileETag MTime Size
  </IfModule>
  <IfModule mod_expires.c>
    # Unset etags if mod_expires exists.
    <IfModule mod_headers.c>
      Header unset ETag
    </IfModule>
    FileETag None
    # Enable expirations.
    ExpiresActive On

    # Cache all aggregated CSS/JS files for 1 year after access (A).
    ExpiresDefault A31556926
  </IfModule>
  <IfModule mod_headers.c>
    # Make these files publicly cacheable.
    Header append Cache-Control "public"
  </IfModule>
</FilesMatch>

What are your settings for gzip on your server currently?

j2b’s picture

mikeytown2, thank you for your feedback. I am currently using only Apache2 settings, not .htaccess file. Is the latest significant? Apache settings implementation was out of the box for Ubuntu server 8.04, where deflate.conf contains the following lines:

<IfModule mod_deflate.c>
          AddOutputFilterByType DEFLATE text/html text/plain text/xml
</IfModule>

And additionally I added the following, to httpd.conf file:

AddOutputFilterByType DEFLATE text/css application/x-javascript
FileETag none

Latest was done without <> tags. By this I assume, that Apache now in total has the following DEFLATE settings:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript

Although I haven't checked setup of AdvAgg module, it seems quite stable for 1.5 days. Should there be significant gain in speed, if AdvAgg module is enabled with this my configuration? And should I still utilize .htaccess file manual configuration, to use AdvAgg module?

Additionally I noticed, that there are some differences between browsers, as mentioned in this link: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html which may take place for somebody to additionaly configure specific needs.

mikeytown2’s picture

Netscape Navigator 4.0 – June 1997
http://en.wikipedia.org/wiki/Netscape_Navigator#Release_history

I don't worry about supporting VERY old browsers.

j2b’s picture

Yes, sorry, agreed, didn't check Apache version, probably soon to be unsupported. For sake of correctness and optional reference, here is Apache v2.2 documentation on Deflate module: http://httpd.apache.org/docs/current/mod/mod_deflate.html

mikeytown2’s picture

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

Ignore edge cases like this. It just clutters up your server configuration.

mikeytown2’s picture

Coming from #974350-57: Far Future setting for Origin Pull mode
I think I can re-work advagg's htaccess rules to be a lot better.

# AdvAgg Rules.
<FilesMatch "^(j|cs)s_[0-9a-f]{32}_.+\.(j|cs)s(\.gz)?">
  # No mod_headers
  <IfModule !mod_headers.c>
    # No mod_expires
    <IfModule !mod_expires.c>
      # Use ETags.
      FileETag MTime Size
    </IfModule>

    # Use Expires Directive.
    <IfModule mod_expires.c>
      # Do not use ETags.
      FileETag None
      # Enable expirations.
      ExpiresActive On
      # Cache all aggregated CSS/JS files for 480 weeks after access (A).
      ExpiresDefault A290304000
    </IfModule>
  </IfModule>

  <IfModule mod_headers.c>
    # Set a far future Cache-Control header to 480 weeks.
    Header set Cache-Control "max-age=290304000, no-transform, public"
    # Set a far future Expires header.
    Header set Expires "Tue, 20 Jan 2037 04:20:42 GMT"
    # Pretend the file was last modified a long time ago in the past.
    Header set Last-Modified "Wed, 20 Jan 1988 04:20:42 GMT"
    # Do not use etags for cache validation.
    Header unset ETag
  </IfModule>
</FilesMatch>
mikeytown2’s picture

Version: 6.x-1.5 » 6.x-1.x-dev
Component: CSS Compression » Code
Status: Active » Fixed
StatusFileSize
new8.42 KB

This patch has been committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.