apache / incubator-pagespeed-ngx

Automatic PageSpeed optimization module for Nginx
http://ngxpagespeed.com/
Apache License 2.0
4.37k stars 364 forks source link

Randomly working/not working prioritize_critical_css #1044

Open sirshurf opened 8 years ago

sirshurf commented 8 years ago

I have enabled prioritize_critical_css.

Now what I can see is that, when I check with PageSpeed I sometimes see it and sometimes I do not, and I see Eliminate render-blocking JavaScript and CSS in above-the-fold content.

Any Ideas?

jeffkaufman commented 8 years ago

How much traffic does your site get? Just your debugging requests or is it getting requests from a lot of people?

(If it's just your debugging or otherwise has very low traffic then the cached information about what css is critical will go stale and you'll have occasional requests without it seeming enabled.)

sirshurf commented 8 years ago

The website as a general and this webpage has a LOTS' of traffic... I was checking on the busies page I have...

sirshurf commented 8 years ago

Any ideas? This is making me mad..... I am not able to fix this! and I do not understand why it's going on.

jeffkaufman commented 8 years ago

It's possible you're running out of cache and the information about what css rules are critical is being evicted. Is your cache at it's default size? How big is your site: how many bytes and how many webpages?

sirshurf commented 8 years ago

The website is HUGE and yes I am usigng default cache settings, but have increased them some a few hours ago... Only I am using memcache for it not filecache here are my settings

# Needs to exist and be writable by nginx.  Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed;
pagespeed FileCacheSizeKb            1024000;
pagespeed FileCacheCleanIntervalMs   3600000;
pagespeed FileCacheInodeLimit        5000000;

pagespeed StatisticsLoggingMaxFileSizeKb 1024;

pagespeed MemcachedServers "cdbf1:11211,cdb2:11211,cdb3:11211,cdbf2:11211";
jeffkaufman commented 8 years ago

How big are your memcached servers combined? The FileCacheSizeKb doesn't have much of an effect if you're running with memcached. (When running memcached only object over 1MB are put in the file cache.)

sirshurf commented 8 years ago

They are actually couchbase via moxi The size of the bucket is: 2.37GB / 3.9GB

I can give you access to the ngx_pagespeed statistics if this will help...

sirshurf commented 8 years ago

Maybe there is some conflict with Cloudflare which is serving my content?

jmarantz commented 8 years ago

If you tell mod_pagespeed to connect its memcached client to a couchbase server, I'm not sure what will happen in terms of timeouts. The default timeout for mod_pagespeed's memcached connection is 50ms, which usually is fine for memcached but might not be adequate for couchbase, and you might need to increase it. See https://developers.google.com/speed/pagespeed/module/system#memcached for a description of the options and details about the stats kept. Also look in the server error-log to see if we are having problems with your memcached connections.

I don't know for sure but I think Cloudflare should not be a problem, unless they are failing to pass through the user-agent and accept headers to servers, which I've seen before with Cloudfront. But I've never heard of this problem with Cloudflare.

-Josh

On Tue, Nov 17, 2015 at 9:41 AM, Alex Frenkel notifications@github.com wrote:

Maybe there is some conflict with Cloudflare which is serving my content?

— Reply to this email directly or view it on GitHub https://github.com/pagespeed/ngx_pagespeed/issues/1044#issuecomment-157388725 .

sirshurf commented 8 years ago

Another point I can see here, is that I see in my HTML in view-source ones some of the elements area dded (like dns prefetch, or image inline...).

Couchbase in memcached mode works more or less like memcached itself... I will try to see any error's in the logs and then increase the timeout to 100 just to check it.

sirshurf commented 8 years ago

OK, after a few tests and checks, it looks like the issue is indeed in Couchbase MOXI connection.

What I see is that it's failing for some reason and getting back, but since it's failed PageSpeed has 30 seconds or so while it waits.

I have installed single MemcacheD and it looks like it's working ok no.

What could be the reason for Couchbase based memcached ????

jmarantz commented 8 years ago

Pagespeed sets a deadline on its cache requests because a slow cache isn't much help if you are trying to make web pages fast. But the deadline can be changed in your configuration.

Memcached is generally very fast when connected directly over a fast LAN to your nginx instance. I don't know much about couchbase but it's possibly that it exchanges speed for persistence.

Josh On Nov 25, 2015 3:59 AM, "Alex Frenkel" notifications@github.com wrote:

OK, after a few tests and checks, it looks like the issue is indeed in Couchbase MOXI connection.

What I see is that it's failing for some reason and getting back, but since it's failed PageSpeed has 30 seconds or so while it waits.

I have installed single MemcacheD and it looks like it's working ok no.

What could be the reason for Couchbase based memcached ????

— Reply to this email directly or view it on GitHub https://github.com/pagespeed/ngx_pagespeed/issues/1044#issuecomment-159539055 .

sirshurf commented 8 years ago

The problem is for all principal things Couchbase is a drop-in replacement for Memcache... And all benchmark I have seen say that the connection speed is practically the same as Memcache with the addition of replication/persistence, that is working in background operations. So yes, it is strange to me that while adding Timeout to 100 I was still getting timeouts.

In any case, case closed. PageSpeed does not working with Couchbase Memcached bucket. I sudgest to add this to the manual.

jmarantz commented 8 years ago

I'm not sure what you mean by "connection speed", but the specific thing pagespeed is looking for is the response time for requests.

Note that couchbase might have a very good average response latency but frequently the requests take longer than average. I can imagine that if it is relying on persistent storage to service a percentage of responses that each of those might be relatively slow.

You can tune pagespeed for this using the histograms on the admin page. Set the timeout very large, say 5 seconds. Then run for a while and look at this histograms for memcached hits, which will tell you 99% latency. Try to find your timeout higher than that.

Please let us know what you find. On Nov 26, 2015 7:42 AM, "Alex Frenkel" notifications@github.com wrote:

The problem is for all principal things Couchbase is a drop-in replacement for Memcache... And all benchmark I have seen say that the connection speed is practically the same as Memcache with the addition of replication/persistence, that is working in background operations. So yes, it is strange to me that while adding Timeout to 100 I was still getting timeouts.

In any case, case closed. PageSpeed does not working with Couchbase Memcached bucket. I sudgest to add this to the manual.

— Reply to this email directly or view it on GitHub https://github.com/pagespeed/ngx_pagespeed/issues/1044#issuecomment-159902783 .

sirshurf commented 8 years ago

I have played with it, and with 200MS I was getting the same errors. So I decided to switch to regular Memcached for pagespeed elements.

But using the memc module for NGINX caching I have timeout at 50ms, and it works there without a problem.

So I do think the problem is in Pagespeed and not on the Couchbase side.

jmarantz commented 8 years ago

What do the histograms look like?

Can you paste the screenshot of http://YOURSITE/pagespeed_admin/histograms after you click on 'memcache_hit_latency' when connected to real memcache vs couchbase?

E.g. you can see similar histograms for modpagespeed.com at http://modpagespeed.com/pagespeed_admin/histograms. That demo site doesn't use memcached but you can see similar histograms there for the shared-memory cache and file-cache.

-Josh

On Sun, Nov 29, 2015 at 3:16 AM, Alex Frenkel notifications@github.com wrote:

I have played with it, and with 200MS I was getting the same errors. So I decided to switch to regular Memcached for pagespeed elements.

But using the memc module for NGINX caching I have timeout at 50ms, and it works there without a problem.

So I do think the problem is in Pagespeed and not on the Couchbase side.

— Reply to this email directly or view it on GitHub https://github.com/pagespeed/ngx_pagespeed/issues/1044#issuecomment-160391031 .