Pagespeed Insight results are not constant (better on desktop, worse on mobile check)

130 views
Skip to first unread message

Alya Ilyashenko

unread,
May 23, 2016, 7:27:22 AM5/23/16
to mod-pagespeed-discuss
Have some weird issue with constancy of pagespeed insights results.Checking homepage 1st time, getting 93/100 on mobile, and 93/100 on desktop.
After some time checking once again, getting 74/100 on mobile and 92/100 on desktop. 
Shouting (for mobile) on Prioritize visible content and Eliminate render-blocking JavaScript and CSS in above-the-fold content.
Once accessing to website from mobile couple times - getting 93/100 again. Site does have some traffic both on mobile and both on desktop.

Here is my mod_pagespeed setup:

ModPagespeedFetchWithGzip on
SetOutputFilter DEFLATE

AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html

 ModPagespeedFileCachePath            "/var/mod_pagespeed/cache/"
  
 ModPagespeedFileCacheSizeKb          102400
 ModPagespeedFileCacheCleanIntervalMs 3600000
 ModPagespeedLRUCacheKbPerProcess     1024
 ModPagespeedLRUCacheByteLimit        16384
 ModPagespeedEnableCachePurge off
 

 ModPagespeedRewriteLevel PassThrough

  ModPagespeedEnableFilters inline_import_to_link
  ModPagespeedEnableFilters rewrite_javascript,rewrite_css,sprite_images
  ModPagespeedEnableFilters rewrite_style_attributes_with_url
  ModPagespeedEnableFilters prioritize_critical_css
  ModPagespeedEnableFilters inline_css
  ModPagespeedEnableFilters combine_css
  ModPagespeedEnableFilters defer_javascript
  ModPagespeedEnableFilters inline_javascript
  ModPagespeedEnableFilters move_css_to_head
  ModPagespeedEnableFilters move_css_above_scripts
  ModPagespeedEnableFilters extend_cache  
  ModPagespeedEnableFilters lazyload_images
  ModPagespeedEnableFilters flatten_css_imports
  ModPagespeedEnableFilters collapse_whitespace,remove_comments,add_head,remove_quotes,convert_meta_tags


  ModPagespeedRespectVary on


<Directory /var/www/mod_pagespeed_example>
  # Any caching headers set on HTML are ignored, and all HTML is served
  # uncacheable.  PageSpeed rewrites HTML files each time they are served.  The
  # first time mod_pagespeed sees an HTML file, it generally won't optimize it
  # fully.  It will optimize better after the second view.  Caching defeats this
  # behavior.

  # Images, styles, and JavaScript are all cache-extended for
  # a year by rewriting URLs to include a content hash.  mod_pagespeed
  # can only do this if the resources are cacheable in the first place.
  # The origin caching policy, set here to 10 minutes, dictates how
  # frequently mod_pagespeed must re-read the content files and recompute
  # the content-hash.  As long as the content doesn't actually change,
  # the content-hash will remain the same, and the resources stored
  # in browser caches will stay relevant.
 
  <FilesMatch "\.(jpg|jpeg|gif|png|js|css)$">
    Header set Cache-control "public, max-age=300"
  </FilesMatch>
</Directory>

 ModPagespeedImgInlineMaxBytes        2048

  ModPagespeedCssOutlineMinBytes       3000
  ModPagespeedJsOutlineMinBytes        3000
  ModPagespeedLazyloadImagesAfterOnload off

  ModPagespeedMaxCombinedJsBytes 300000
  ModPagespeedMaxSegmentLength 2048
  ModPagespeedMaxCombinedCssBytes -1
  ModPagespeedJsInlineMaxBytes 20512
  ModPagespeedCssInlineMaxBytes 20512



  ModPagespeedMaxSegmentLength 250

Joshua Marantz

unread,
May 23, 2016, 7:56:00 AM5/23/16
to pagespeed-insights-discuss, mod-pagespeed-discuss
It makes sense that you sent that to both mod-pagespeed-discuss and pagespeed-insights-discuss, and in this case I think it's a mod_pagespeed issue.

This is likely a result of not having enough traffic on your site to keep the critical-css cache fresh.  By default, mod_pagespeed's critical-css property cache expires after 5 minutes, so the first few views after expiry are likely to not get the optimization.  When there is a steady stream of traffic, the cache should generally be refreshed before it expires.

There's an open bug https://github.com/pagespeed/mod_pagespeed/issues/1311 to give users the ability to adjust that timeout value.  However, in this case I think you might also run into the 5-minute cache-control you gave your CSS files in your apache configuration.

Another approach is to set up a script with PhantomJS to crawl and render your site every minute.  That will keep your caches fresh.  If you try this and get something working, please follow up.  It would be great to share those scripts with other users that have the same challenges.

-Josh

--
You received this message because you are subscribed to the Google Groups "pagespeed-insights-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pagespeed-insights-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pagespeed-insights-discuss/b90d9486-88e8-4c09-bd5f-6c9a45041671%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alya Ilyashenko

unread,
May 23, 2016, 9:39:08 AM5/23/16
to mod-pagespeed-discuss, pagespeed-ins...@googlegroups.com
Thank you Josh for your input. 
The issue is that sometimes I visit page couple times and score is not improving (sometimes it does), than, if i run this command touch `grep "^ *ModPagespeedFileCachePath" /usr/local/apache/conf/pagespeed.conf | awk ' { print $2; } ' | sed 's/"//g'`/cache.flush  and visit page, I get 93/100 on both mobile and desktop again. 
To unsubscribe from this group and stop receiving emails from it, send an email to pagespeed-insights-discuss+unsub...@googlegroups.com.

Kim Frederiksen

unread,
Jun 28, 2016, 7:27:00 AM6/28/16
to mod-pagespeed-discuss, pagespeed-ins...@googlegroups.com
We have successfully used PhantomJS to fix the issue by setting up a cronjob using one of the provided example scripts from PhantomJS

phantomjs /opt/phantomjs/examples/loadspeed.js http://www.lambaek-services.dk >/dev/null 2>&1

We are running this every 2 mins, and seems to work like a charm.

This particular approach is a quick fix for us, as we use frontpages to demonstrate high scores in insights. To use this in practical real life situations, seems like a bad decision, as it is pretty resource intensive to do this on every page of a larger website or servers with many virtual hosts. We still like this approach until it becomes possible to configure longer expirations in the configuration.

Thanks,

Kim
To unsubscribe from this group and stop receiving emails from it, send an email to pagespeed-insights-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages