How to convert all images for .WebP with OptimizeForBandwidth active

1,019 views
Skip to first unread message

emersong...@gmail.com

unread,
Nov 7, 2017, 10:19:47 PM11/7/17
to mod-pagespeed-discuss
Greetings,
I have mod_pagespeed installed with the Optimize For Bandwidth directive. I own a shared hosting and this allows me to automatically optimize my clients' websites without breaking them.
However I would also like to convert the images automatically to .WebP and although I added the directive to do this it just is not working. Is it possible to use these features without changing the urls?
And even if I need to change the urls I have to activate this feature, as long as it does not affect CSS & JS ...
Here's my pagespeed.conf file for reference:
<IfModule !mod_version.c> LoadModule version_module modules/mod_version.so </IfModule> <IfVersion < 2.4> LoadModule pagespeed_module modules/mod_pagespeed.so </IfVersion> <IfVersion >= 2.4.2> LoadModule pagespeed_module modules/mod_pagespeed_ap24.so </IfVersion> <IfModule pagespeed_module> # Turn on mod_pagespeed. To completely disable mod_pagespeed, you # can set this to "off". ModPagespeed on # Direct Apache to send all HTML output to the mod_pagespeed # output handler. AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html # The ModPagespeedFileCachePath and # ModPagespeedGeneratedFilePrefix directories must exist and be # writable by the apache user (as specified by the User # directive). ModPagespeedFileCachePath "/var/mod_pagespeed/cache/" # Override the mod_pagespeed 'rewrite level'. The default level # "CoreFilters" uses a set of rewrite filters that are generally # safe for most web pages. Most sites should not need to change # this value and can instead fine-tune the configuration using the # ModPagespeedDisableFilters and ModPagespeedEnableFilters # directives, below. Valid values for ModPagespeedRewriteLevel are # PassThrough, CoreFilters, TestingCoreFilters and AllFilters. # # ModPagespeedRewriteLevel PassThrough # Explicitly disables specific filters. This is useful in # conjunction with ModPagespeedRewriteLevel. For instance, if one # of the filters in the CoreFilters needs to be disabled for a # site, that filter can be added to # ModPagespeedDisableFilters. This directive contains a # comma-separated list of filter names, and can be repeated. # # ModPagespeedDisableFilters rewrite_images # Explicitly enables specific filters. This is useful in # conjunction with ModPagespeedRewriteLevel. For instance, filters # not included in the CoreFilters may be enabled using this # directive. This directive contains a comma-separated list of # filter names, and can be repeated. # # ModPagespeedEnableFilters rewrite_javascript,rewrite_css # ModPagespeedEnableFilters collapse_whitespace,elide_attributes # ModPagespeedDomain # authorizes rewriting of JS, CSS, and Image files found in this # domain. By default only resources with the same origin as the # HTML file are rewritten. For example: # # ModPagespeedDomain cdn.myhost.com # # This will allow resources found on http://cdn.myhost.com to be # rewritten in addition to those in the same domain as the HTML. # # Wildcards (* and ?) are allowed in the domain specification. Be # careful when using them as if you rewrite domains that do not # send you traffic, then the site receiving the traffic will not # know how to serve the rewritten content. # Other defaults (cache sizes and thresholds): # ModPagespeedFileCacheSizeKb 102400 ModPagespeedFileCacheCleanIntervalMs 3600000 ModPagespeedLRUCacheKbPerProcess 1024 ModPagespeedLRUCacheByteLimit 16384 ModPagespeedCssInlineMaxBytes 2048 ModPagespeedImgInlineMaxBytes 2048 ModPagespeedJsInlineMaxBytes 2048 ModPagespeedCssOutlineMinBytes 3000 ModPagespeedJsOutlineMinBytes 3000 # Bound the number of images that can be rewritten at any one time; this # avoids overloading the CPU. Set this to 0 to remove the bound. # # ModPagespeedImgMaxRewritesAtOnce 8 # When Apache is set up as a browser proxy, mod_pagespeed can record # web-sites as they are requested, so that an image of the web is built up # in the directory of the proxy administrator's choosing. When ReadOnly is # on, only files already present in the SlurpDirectory are served by the # proxy. # # ModPagespeedSlurpDirectory ... # ModPagespeedSlurpReadOnly on # The maximum URL size is generally limited to about 2k characters # due to IE: See http://support.microsoft.com/kb/208427/EN-US. # Apache servers by default impose a further limitation of about # 250 characters per URL segment (text between slashes). # mod_pagespeed circumvents this limitation, but if you employ # proxy servers in your path you may need to re-impose it by # overriding the setting here. The default setting is 1024 # characters. # # ModPagespeedMaxSegmentLength 250 # Uncomment this if you want to prevent mod_pagespeed from combining files # (e.g. CSS files) across paths # # ModPagespeedCombineAcrossPaths off # Whether or not to log timing information for rewriting filters. # Off by default to keep logs uncluttered. # # ModPagespeedLogRewriteTiming on # Enables server-side instrumentation and statistics. If this rewriter is # enabled, then each rewritten HTML page will have instrumentation javacript # added that sends latency beacons to /mod_pagespeed_beacon. These # statistics can be accessed at /mod_pagespeed_statistics. You must also # enable the mod_pagespeed_statistics and mod_pagespeed_beacon handlers # below. # # ModPagespeedEnableFilters add_instrumentation # This handles the client-side instrumentation callbacks which are injected # by the add_instrumentation filter. # You can use a different location by adding the ModPagespeedBeaconUrl # directive; see the documentation on add_instrumentation. <Location /mod_pagespeed_beacon> SetHandler mod_pagespeed_beacon </Location> # Uncomment the following line if you want to disable statistics entirely. # # ModPagespeedStatistics off # This page lets you view statistics about the mod_pagespeed module. <Location /mod_pagespeed_statistics> Order allow,deny # You may insert other "Allow from" lines to add hosts you want to # allow to look at generated statistics. Another possibility is # to comment out the "Order" and "Allow" options from the config # file, to allow any client that can reach your server to examine # statistics. This might be appropriate in an experimental setup or # if the Apache server is protected by a reverse proxy that will # filter URLs in some fashion. Allow from localhost SetHandler mod_pagespeed_statistics </Location> ### Ricardo ### ModPagespeedInheritVHostConfig on ModPagespeedRewriteLevel OptimizeForBandwidth <VirtualHost *:80> ServerName velocidade.host ModPagespeedEnableFilters inline_javascript,prioritize_critical_css,inline_preview_images,sprite_images,rewrite_images,rewrite_css,recompress_png </VirtualHost> <VirtualHost *:80> ServerName velocidade.host ModPagespeedCssPreserveURLs off </VirtualHost> <VirtualHost *:80> ServerName velocidade.host ModPagespeedRewriteLevel CoreFilters </VirtualHost> ModPagespeedEnableFilters responsive_images,resize_images,lazyload_images ModPagespeedEnableFilters convert_jpeg_to_webp,convert_to_webp_lossless,convert_to_webp_animated,recompress_webp # ModPagespeedEnableFilters combine_css,prioritize_critical_css,rewrite_css,fallback_rewrite_css_urls # ModPagespeedEnableFilters canonicalize_javascript_libraries,rewrite_javascript,defer_javascript ModPagespeedEnableFilters collapse_whitespace,extend_cache,trim_urls,remove_comments ModPagespeedForceCaching on ModPagespeedEnableCachePurge on ### fim ### </IfModule>


emersong...@gmail.com

unread,
Nov 7, 2017, 10:32:56 PM11/7/17
to mod-pagespeed-discuss
Due to formatting problems of the forum I am posting in pastebin, follow the configuration file of pagespeed:

Otto van der Schaaf

unread,
Nov 8, 2017, 2:56:02 AM11/8/17
to mod-pagesp...@googlegroups.com
You could have a look  enabling browser-specific in-place optimization:

Otto


On Wed, Nov 8, 2017 at 4:32 AM <emersong...@gmail.com> wrote:
Due to formatting problems of the forum I am posting in pastebin, follow the configuration file of pagespeed:

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/bdf05713-6c17-4c72-8fb1-bf0c82dd1ffe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joshua Marantz

unread,
Nov 8, 2017, 7:10:02 AM11/8/17
to mod-pagespeed-discuss
How do you know it isn't working?  In OptimizeForBandwidth mode, the filenames are not renamed but the Content-Type changes as well as the bytes.  Vary:Accept is added to the response headers to help proxy caches distinguish the two different payloads for the same url.


On Nov 8, 2017 2:56 AM, "Otto van der Schaaf" <osc...@we-amp.com> wrote:
You could have a look  enabling browser-specific in-place optimization:

Otto


On Wed, Nov 8, 2017 at 4:32 AM <emersong...@gmail.com> wrote:
Due to formatting problems of the forum I am posting in pastebin, follow the configuration file of pagespeed:

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/CAHqmWiNrjdjeVrB-oKDpTtPsPj6xG7Ky71h-tPC-zmtuU6-ogA%40mail.gmail.com.

emersong...@gmail.com

unread,
Nov 8, 2017, 8:06:19 AM11/8/17
to mod-pagespeed-discuss
Exactly, I saw that it is not working because the content-type has not changed and none have seen a significant change in the size of the images.

Joshua Marantz

unread,
Nov 8, 2017, 8:16:57 AM11/8/17
to mod-pagespeed-discuss
What comes out in the logs when you request a jpeg that's not being converted? Not sure if this is clear, but typically it takes 3 or so refreshes before an image is delivered optimized in OptimizeForBandwidth mode.

I took a quick look at your config and I'd recommend turning off ModPagespeedForceCaching. That's really for debugging and should not be enabled in production.


--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+unsub...@googlegroups.com.

emersong...@gmail.com

unread,
Nov 8, 2017, 9:36:40 AM11/8/17
to mod-pagespeed-discuss
Where are these log files you are suggesting? Does it tell Apache access logs?
I made the change you suggested and unveiled the "ForcaCaching"
Here is the site that is being optimized by pagespeed, however the images are not being converted to .WebP
I also do not know how to clear the cache, just restart apache after applying the changes, is that right?

Em quarta-feira, 8 de novembro de 2017 00:19:47 UTC-3, emersong...@gmail.com escreveu:

Joshua Marantz

unread,
Nov 8, 2017, 9:48:24 AM11/8/17
to mod-pagespeed-discuss
I think you don't need to clear the cache; it should pick up changes in the config as needed.

The error log I was referring to is the Apache error log, which might be at /var/logs/apache2/error.log depending on your distro.  That's where they are on Ubuntu.

-Josh


--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+unsub...@googlegroups.com.

emersong...@gmail.com

unread,
Nov 8, 2017, 10:41:30 PM11/8/17
to mod-pagespeed-discuss
[Wed Nov 08 23:54:33.194497 2017] [core:notice] [pid 1360:tid 139843256653952] AH00094: Command line: '/usr/sbin/httpd'
[Wed Nov 08 23:54:47.807800 2017] [mpm_worker:notice] [pid 1360:tid 139843256653952] AH00297: SIGUSR1 received.  Doing graceful restart
[Wed Nov 08 23:54:48.020953 2017] [ssl:warn] [pid 1360:tid 139843256653952] AH01909: nt4gbi.montarumnegocio.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Nov 08 23:54:48.027726 2017] [ssl:warn] [pid 1360:tid 139843256653952] AH01909: fabricadechinelos.montarumnegocio.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Nov 08 23:54:48.029117 2017] [ssl:warn] [pid 1360:tid 139843256653952] AH01909: depilacaodesucesso.montarumnegocio.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Nov 08 23:54:48.030524 2017] [ssl:warn] [pid 1360:tid 139843256653952] AH01909: comoguardar.montarumnegocio.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Nov 08 23:54:48.034196 2017] [ssl:warn] [pid 1360:tid 139843256653952] AH01909: viverdebrownie.negociodecozinha.com.br:443:0 server certificate does NOT include an ID which matches the server name
[Wed Nov 08 23:54:48.038693 2017] [lbmethod_heartbeat:notice] [pid 1360:tid 139843256653952] AH02282: No slotmem from mod_heartmonitor
[Wed Nov 08 23:54:48.251534 2017] [http2:info] [pid 1360:tid 139843256653952] AH03090: mod_http2 (v1.10.12, feats=CHPRIO+SHA256+INVHD+DWINS, nghttp2 1.20.0), initializing...
[Wed Nov 08 23:54:48.252179 2017] [mpm_worker:notice] [pid 1360:tid 139843256653952] AH00292: Apache/2.4.29 (cPanel) OpenSSL/1.0.2m mod_bwlimited/1.4 configured -- resuming normal operations
[Wed Nov 08 23:54:48.252210 2017] [core:notice] [pid 1360:tid 139843256653952] AH00094: Command line: '/usr/sbin/httpd'
[Thu Nov 09 00:01:11.456596 2017] [pagespeed:error] [pid 20537:tid 139842274936576] [mod_pagespeed 1.12.34.2-0 @20537] Slow ReadFile operation on file /var/mod_pagespeed/cache/v3/fabricadechinelos.com/http,3A/,2Ffabricadechinelos.com/borracha-para-fazer-chinelos/amp/,: 107.212ms; configure SlowFileLatencyUs to change threshold\n
[Thu Nov 09 00:04:27.364567 2017] [pagespeed:warn] [pid 20507:tid 139841910073088] [mod_pagespeed 1.12.34.2-0 @20507] CSS parsing error in http://depilacaodesucesso.com.br/wp-content/cache/min/1/8d3abb895f865cbd0ba4b591fc88d0b6.css
[Thu Nov 09 00:05:02.992537 2017] [pagespeed:error] [pid 20507:tid 139842170038016] [mod_pagespeed 1.12.34.2-0 @20507] Slow ReadFile operation on file /var/mod_pagespeed/cache/v3/depilacaodesucesso.com.br/http,3A/,2Fdepilacaodesucesso.com.br/curso-de-depilacao-em-campo-grande/amp/,: 59.286ms; configure SlowFileLatencyUs to change threshold\n

It is ok ?

Em quarta-feira, 8 de novembro de 2017 00:19:47 UTC-3, emersong...@gmail.com escreveu:
Reply all
Reply to author
Forward
0 new messages