Do I misunderstand pagespeeds ImagePreserveURLs on ?

392 views
Skip to first unread message

Michael N.

unread,
Jan 26, 2017, 6:18:49 AM1/26/17
to mod-pagespeed-discuss
Hi guys,


the way I understood the option ImagePreserveURLs is, that if enabled, the actual image names do not change.

So instead of having 740xNxAmsterdam_mikeinlondon_ISTOCK-532566508.jpg.pagespeed.ic.X-529UpNiw.webp I still would have Amsterdam_mikeinlondon_ISTOCK-532566508.jpg as the name of the image, even though its resized and recompressed (according to my other configuration)

This would be very important for us, since we use ReactJS which rerenders the site when the resource name has changed. This leads to dynamic components always get rerendered which then loads the huge original versions of the images ...

So is this option supposed to keep the name of the file and it's just not working properly or do I misunderstand what it's supposed to be doing?

thanks & best regards,

Michael

Otto van der Schaaf

unread,
Jan 26, 2017, 6:31:15 AM1/26/17
to mod-pagespeed-discuss
Glossing over the code [1], enabling image resizing and/or inlining will override the image url preservation option.
Those optimizations cannot be performed without changing the url.

[1]
void ImageRewriteFilter::ComputePreserveUrls(
    const RewriteOptions* options, ResourceSlot* slot) {
  // Note that in RewriteOptions::Merge we turn off image_preserve_urls                                                                                                                                                                                 
  // when merging into a configuration that has explicitly                                                                                                                                                                                              
  // enabled cache_extend_images.                                                                                                                                                                                                                       
  //                                                                                                                                                                                                                                                    
  // Consider a hosting provider that turns on "optimize for                                                                                                                                                                                            
  // bandwidth" mode, and then a site enables resize_images                                                                                                                                                                                             
  // explicitly.  That should override the image-url-preservation                                                                                                                                                                                       
  // default that was set at root.  Note that explicitly turning on                                                                                                                                                                                     
  // RecompressImages doesn't mean we'll want to override                                                                                                                                                                                               
  // image_preserve_urls rewrite URLs here, since we can still get                                                                                                                                                                                      
  // the benefit of recompression via IPRO.  But we make an                                                                                                                                                                                             
  // exception for inlining and image-resizing directives since                                                                                                                                                                                         
  // those can only be done via url-rewriting.                                                                                                                                                                                                          
  if (options->image_preserve_urls() &&
      !options->Enabled(RewriteOptions::kResizeImages) &&
      !options->Enabled(RewriteOptions::kResizeToRenderedImageDimensions) &&
      !options->Enabled(RewriteOptions::kInlineImages)) {
    slot->set_preserve_urls(true);
  }
}
Otto

--
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/a6708ff5-1ce6-47b3-8313-bff425cafe5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael N.

unread,
Jan 26, 2017, 7:32:49 AM1/26/17
to mod-pagespeed-discuss
The documentation says:

Enabling image_preserve_urls will forbid the use of the following filters: inline_preview_images,lazyload_imagesextend_cache_imagesinline_images, and sprite_images.

I explicitly disable these filters in my config. The documentation does not mention resize_images or resize_images_rendered_dimensions, but the code doesn't lie I guess.

So, not exactly what I was hoping to hear, but tank you anyways. I greatly appreciate it.

Michael

To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+unsub...@googlegroups.com.

Joshua Marantz

unread,
Jan 26, 2017, 8:31:20 AM1/26/17
to mod-pagespeed-discuss
Yes, the doc MIchael quotes was written when ImagePreserveUrls was created (and had that 'forbid') property, and was correct at the time it was written.

Then we added OptimizeForBandwidth, which layered more configuration complexity over that concept.  That doc needs to be updated (which can now be done with a github pull.



Michael

To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+unsubscri...@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.
Reply all
Reply to author
Forward
0 new messages