apache / incubator-pagespeed-mod

Apache module for rewriting web pages to reduce latency and bandwidth.
http://modpagespeed.com
Apache License 2.0
696 stars 158 forks source link

Mobile devices Web Page Performance very low Desktop improved #1991

Open Chathu07 opened 4 years ago

Chathu07 commented 4 years ago

I use a responsive theme and use a LEMP stack and use the WordPress platform.

When I test the site performance using the pagespeed insights, I can achieve 81% score for the desktop site but mobile site score less than 30%.

Below you can find my configuration file. My I know which filters improve the mobile site performance?

pagespeed on;

add header

pagespeed XHeaderValue "Powered By ngx_pagespeed";

location ~ ".pagespeed.([a-z].)?[a-z]{2}.[^.]{10}.[^.]+" { add_header " " " "; }

location ~ "^/pagespeed_static/" { } location ~ "^/ngx_pagespeed_beacon$" { }

Disable PageSpeed Core Filters and enabale one by one.

pagespeed RewriteLevel PassThrough;

pagespeed FileCachePath /var/cache/ngx_pagespeed_cache;

pagespeed AllowVaryOn "Auto";

Cause Render Blocking CSS

pagespeed EnableFilters hint_preload_subresources;

pagespeed UseExperimentalJsMinifier on;

Sizes

pagespeed JsOutlineMinBytes 3000; pagespeed MaxCombinedCssBytes -1; pagespeed MaxCombinedJsBytes -1;

pagespeed CssInlineMaxBytes 28000;

pagespeed JsInlineMaxBytes 16096;

pagespeed LazyloadImagesAfterOnload on;

pagespeed RewriteDeadlinePerFlushMs 2000; pagespeed MaxCacheableContentLength 2048000;

pagespeed FetchHttps enable,allow_self_signed;

Implicit cache-lifetime for resources

pagespeed ImplicitCacheTtlMs 3600000;

In-memory LRU Cache

pagespeed LRUCacheKbPerProcess 16192; pagespeed LRUCacheByteLimit 64384;

pagespeed EnableCachePurge on; pagespeed PurgeMethod PURGE;

pagespeed LoadFromFileRuleMatch disallow .*; pagespeed LoadFromFileRuleMatch allow .css$ps_dollar; pagespeed LoadFromFileRuleMatch allow .jpe?g$ps_dollar; pagespeed LoadFromFileRuleMatch allow .png$ps_dollar; pagespeed LoadFromFileRuleMatch allow .gif$ps_dollar; pagespeed LoadFromFileRuleMatch allow .js$ps_dollar; pagespeed LoadFromFileRuleMatch allow .ico$ps_dollar; pagespeed LoadFromFileRuleMatch allow .svg$ps_dollar; pagespeed LoadFromFileRuleMatch allow .php$ps_dollar;

pagespeed Disallow /js/buzz.js;

pagespeed Disallow */lost-password/lost;

pagespeed Disallow /lost-password/;

pagespeed Disallow /cron.php; pagespeed Disallow /admin.php;

pagespeed DownstreamCacheRebeaconingKey "{{PAGESPEED_BEACON}}";

pagespeed RespectVary on; pagespeed RespectXForwardedProto on;

pagespeed LowercaseHtmlNames on;

JavaScript Optimization.

pagespeed EnableFilters rewrite_javascript,outline_javascript,combine_javascript,extend_cache,local_storage_cache,canonicalize_javascript_libraries,defer_javascript;

Other Optimization.

pagespeed EnableFilters insert_dns_prefetch,add_head; pagespeed RetainComment " google_ad_section*"; pagespeed EnableFilters trim_urls;

3rd Party script Optimization.

pagespeed EnableFilters inline_google_font_css; pagespeed EnableFilters make_show_ads_async; pagespeed EnableFilters make_google_analytics_async;

HTML Optimization.

pagespeed EnableFilters elide_attributes,remove_comments,combine_heads,collapse_whitespace;

CSS Optimization.

pagespeed EnableFilters prioritize_critical_css,rewrite_css,combine_css,fallback_rewrite_css_urls,flatten_css_imports,inline_css,inline_import_to_link,rewrite_style_attributes_with_url,move_css_above_scripts,move_css_to_head; pagespeed PermitIdsForCssCombining *-css;

Image Optimization.

pagespeed EnableFilters inline_preview_images,resize_rendered_image_dimensions,insert_image_dimensions,responsive_images,lazyload_images,dedup_inlined_images,inline_images,rewrite_images,recompress_images,rewrite_css,sprite_images;

Mobile Optimization.

pagespeed EnableFilters resize_mobile_images;

Browser Optimization

pagespeed EnableFilters convert_meta_tags;

redis storage backend

pagespeed RedisServer "{{REDIS_UPSTREAM}}";

pagespeed RedisTimeoutUs 1000;

Combine CSS wildcard.

pagespeed PermitIdsForCssCombining font*; pagespeed MinImageSizeLowResolutionBytes 10;

Extend Cache

pagespeed EnableFilters extend_cache;

Fix PageSpeed remove comment AMP validation error.

pagespeed RetainComment "AMP_VALIDATION:*";

Disable meta refresh.

pagespeed SupportNoScriptEnabled false;

Lofesa commented 4 years ago

Hi First, pagespeed module do nothing with ico,svg nor php files, so you don´t need these lines:

pagespeed LoadFromFileRuleMatch allow .ico$ps_dollar;
pagespeed LoadFromFileRuleMatch allow .svg$ps_dollar;
pagespeed LoadFromFileRuleMatch allow .php$ps_dollar;

In fact, I think you need to include these file extensions in the disallow section. My score for your site is 81 mobile 95 desktop, if your site still the same (drcrhub). I see you have issues with render blocking with css and js files. For css files you may take a look to the filters you have set: If you enable prioritize_critical_css, I think you don´t need any of the inline filters nor any of the move filters For the js files, I don´t know why the defer_javascript is not working, but you need to set the js script w/ defer or async attributes For the filter inline_google_font_css you need, like css or js inline filters, the size with pagespeed GoogleFontCssInlineMaxBytes bytes; And you have TTFB issues too, so you need to optimize the nginx server for better TTFB, for example tunning the ssl config ( read https://haydenjames.io/nginx-tuning-tips-tls-ssl-https-ttfb-latency/)

Take account that the Ligthhouse test for mobile emulates a very slow connection, with a fixed 150ms RTT and 1.6Mbps

And maybe using cloudflare you have trouble with optimized resources and the clodflare cache. In fact i can´t test you site cause it.

Chathu07 commented 4 years ago

Dear @Lofesa thank you for your reply. Problem is that I use Contact Form 7 with ReCaptcha v3. After I disabled it again site perform well. I have tested https://foodsreborn.com/ site. But still I have image lazy loading issue.

When I debug I get following response. Please look at its DelayImages and Lazyload Images both automatically disabled.

`

mod_pagespeed on

  | Filters:   | ah Add Head   | ij Canonicalize Javascript library URLs   | cw Collapse Whitespace   | cc Combine Css   | ch Combine Heads   | jc Combine Javascript   | gp Convert Gif to Png   | jp Convert Jpeg to Progressive   | jw Convert Jpeg To Webp   | mc Convert Meta Tags   | pj Convert Png to Jpeg   | ws When converting images to WebP, prefer lossless conversions   | db Debug   | dd Dedup Inlined Images   | dj Defer Javascript   | di Delay Images   | ea Elide Attributes   | ec Cache Extend Css   | ei Cache Extend Images   | es Cache Extend Scripts   | fc Fallback Rewrite Css   | if Flatten CSS Imports   | hw Flushes html   | ci Inline Css   | gf Inline Google Font CSS   | ii Inline Images   | il Inline @import to Link   | idp Insert DNS Prefetch   | id Insert Image Dimensions   | js Jpeg Subsampling   | ll Lazyload Images   | tu Left Trim Urls   | ls Local Storage Cache   | ga Make Google Analytics Async   | gaa Convert showads.js use to async adsbygoogle.js   | cj Move Css Above Scripts   | cm Move Css To Head   | jo Outline Javascript   | pr Prioritize Critical Css   | rj Recompress Jpeg   | rp Recompress Png   | rw Recompress Webp   | rc Remove Comments   | ri Resize Images   | rm Resize Mobile Images   | ir Resize to Rendered Image Dimensions   | rx Responsive Images   | cf Rewrite Css   | rd Rewrite Domains   | jm Rewrite External Javascript   | jj Rewrite Inline Javascript   | cu Rewrite Style Attributes With Url   | is Sprite Images   | cp Strip Image Color Profiles   | md Strip Image Meta Data   |     | Options:   | AllowVaryOn (avo) Auto   | AvoidRenamingIntrospectiveJavascript (aris) True   | CssInlineMaxBytes (ci) 28000   | EnableCachePurge (euci) True   | EnableRewriting (e) 1   | FetchWithGzip (afg) True   | FileCacheCleanIntervalMs (afcci) 7776000000   | FileCacheInodeLimit (afcl) 429497   | FileCacheSizeKb (afc) 2097152   | GoogleFontCssInlineMaxBytes (gfci) 20000   | HttpCacheCompressionLevel (hccl) 9   | ImageMaxRewritesAtOnce (im) 1000   | ImplicitCacheTtlMs (ict) 3600000   | InPlaceSMaxAgeSec (ipsm) 10   | IproMaxConcurrentRecordings (imcr) 100   | JsOutlineMinBytes (jo) 3000   | LazyloadImagesAfterOnload (llio) True   | LoadFromFileCacheTtlMs (lfct) 2592000000   | LowercaseHtmlNames (lh) True   | LRUCacheByteLimit (alcb) 64384   | LRUCacheKbPerProcess (alcp) 16192   | MaxCacheableContentLength (rcl) 2048000   | MaxCombinedCssBytes (xcc) -1   | MaxCombinedJsBytes (xcj) -1   | MinImageSizeLowResolutionBytes (nislr) 10   | RespectVary (rv) True   | RespectXForwardedProto (rxfp) True   | RewriteDeadlinePerFlushMs (rdm) 2000   | RewriteLevel (l) Pass Through   | Statistics (ase) True   | StatisticsLogging (asle) True   | StatisticsLoggingIntervalMs (asli) 1800000   | SupportNoScriptEnabled (snse) False   | UseExperimentalJsMinifier (uejsm) True   | XHeaderValue (xhv) Powered By ngx_pagespeed   |     | #NumFlushes 0   | #EndDocument after 96543us   | #Total Parse duration 2909us   | #Total Render duration 561103us   | #Total Idle duration 93634us   | No critical images detected.   | The following filters were disabled for this request:   | DelayImages   | Lazyload Images   | -->

`

Lofesa commented 4 years ago

These filters are disabled for "this" request. "this" is the wrod. For lazyload/delay images pagespeed need some info that take some time to collect. The info como back to pagespeed server via the beacons. ¿What positio have the images related to the viewport? ¿What distance from the star of page maybe considered as a "frontier" to show or not images? These questions need info, these info is collected by the javascript injected in the page when the beacon is working and reported to the server via POST request. Take a look at the server log files, you must see some log request type POST whit ngx_pagespeed_beacon in the url