Use pagespeed with maxCDN

302 views
Skip to first unread message

webspher

unread,
Aug 20, 2016, 7:20:44 AM8/20/16
to mod-pagespeed-discuss
Hi there, hope you're all fine!

I'm currently testing maxCDN but I must admin that i'm a little disappointed from the fact that i can't use pagespeed as before.
First I would like to know if I really do need the CDN as my main target is only in Europe, I heard that google has its own CDN, how is it comparing to maxCDN?

In the case i keep using maxCDN, i want to keep using pagespeed (combining css and js files), I searched in the group and found that ModPagespeedMapRewriteDomain cdn.example.com *example.com is the solution, i've tried it before but didn't seem to work. Is there anything else i should do?

Thanks a lot for your inlights
Have a lovely weekend

Otto van der Schaaf

unread,
Aug 20, 2016, 8:57:53 AM8/20/16
to mod-pagespeed-discuss
- Can you explain more about what the specific problem is that prevents you from using pagespeed when you test maxCDN?

- As for needing a CDN, if you want to measure its impact you could run an A/B test to measure how this (and other) CDN's impact speed for your audience.
Depending on how you have the CDN set up for your website, that's something pagespeed may be able to help with (if you use pagespeed to rewrite assets to the cdn):
If your www. is served via the CDN you'll need to figure out another way to do this though.

- About MapRewriteDomain: can you post more details on what happened when you added that configuration, and what you would have expected to happen? Note that if you would have expected non .pagespeed. urls to be rewritten: for that to happen you also need to enable rewrite_domains:

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/923091c8-15f9-4076-93a0-c2953544049a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joshua Marantz

unread,
Aug 20, 2016, 2:09:32 PM8/20/16
to mod-pagespeed-discuss
I also want to point out that MapRewriteDomain may be what you want.  That's designed for mapping resources on your own site to a pull-CDN.  That might be simpler to get working than MapProxyDomain.

MapProxyDomain can be be used for mapping resources hosted on *other* sites to your own site, or directly to your CDN.  For example, you could proxy and optimize images hosted on a photo-sharing site with MapProxyDomain.

-Josh

On Sat, Aug 20, 2016 at 8:57 AM, Otto van der Schaaf <osc...@we-amp.com> wrote:
- Can you explain more about what the specific problem is that prevents you from using pagespeed when you test maxCDN?

- As for needing a CDN, if you want to measure its impact you could run an A/B test to measure how this (and other) CDN's impact speed for your audience.
Depending on how you have the CDN set up for your website, that's something pagespeed may be able to help with (if you use pagespeed to rewrite assets to the cdn):
If your www. is served via the CDN you'll need to figure out another way to do this though.

- About MapRewriteDomain: can you post more details on what happened when you added that configuration, and what you would have expected to happen? Note that if you would have expected non .pagespeed. urls to be rewritten: for that to happen you also need to enable rewrite_domains:

Otto



On Sat, Aug 20, 2016 at 1:20 PM webspher <red...@gmail.com> wrote:
Hi there, hope you're all fine!

I'm currently testing maxCDN but I must admin that i'm a little disappointed from the fact that i can't use pagespeed as before.
First I would like to know if I really do need the CDN as my main target is only in Europe, I heard that google has its own CDN, how is it comparing to maxCDN?

In the case i keep using maxCDN, i want to keep using pagespeed (combining css and js files), I searched in the group and found that ModPagespeedMapRewriteDomain cdn.example.com *example.com is the solution, i've tried it before but didn't seem to work. Is there anything else i should do?

Thanks a lot for your inlights
Have a lovely weekend

--
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/CAHqmWiOC%3DXrJE8KB07xJq8qK82GzZnP2ekcyBX2F1LRrkskjoA%40mail.gmail.com.

webspher

unread,
Aug 22, 2016, 8:17:28 AM8/22/16
to mod-pagespeed-discuss
Thank you Otto and Josh for your replies

I remember when I used "MapRewriteDomain" to be able to rewrite file names and also combine css & js assets, nothing was happening and didn't manage to do it... I'll run some few more test very soon and will let you know.
As per now our server is managed by an external company, i'm wondering if there is a way to edit the pagespeed configuration without asking them to make all the changes..!

Thanks a lot for your help

Joshua Marantz

unread,
Aug 22, 2016, 8:23:12 AM8/22/16
to mod-pagespeed-discuss
With shared hosting, usually the easiest configuration mechanism is to put your pagespeed directives in .htaccess files alongside your content.  You can use the domain-mapping directives in .htaccess files.

-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.

webspher

unread,
Aug 23, 2016, 5:56:07 AM8/23/16
to mod-pagespeed-discuss
Thank you Josh for your reply.

I tried to add some directives inside <directory> in the .htaccess but i didn't manage to.

<Directory />
ModPagespeed off
</Directory>

Am I missing something??

Joshua Marantz

unread,
Aug 23, 2016, 7:36:28 AM8/23/16
to mod-pagespeed-discuss

I don't think you use the <directory> command in htaccess files.  The directory scope is instead determined from the location of the htaccess file itself.


--
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.

webspher

unread,
Aug 23, 2016, 8:22:07 AM8/23/16
to mod-pagespeed-discuss
Do you please have an example of using pagespeed config in an .htaccess file? i didn't find anything related to it!!

Jeff Kaufman

unread,
Aug 23, 2016, 9:43:00 AM8/23/16
to mod-pagespeed-discuss
Just put the command directly in your .htaccess file. For example,
here's one we use for testing:

$ cat mod_pagespeed_test/htaccess/.htaccess
ModPagespeedDisallow *

(Not that ModPagespeedDisallow is the right command for your
situation, though, it's just an example of how to do it.)

On Tue, Aug 23, 2016 at 8:22 AM, webspher <red...@gmail.com> wrote:
> Do you please have an example of using pagespeed config in an .htaccess
> file? i didn't find anything related to it!!
>
> --
> 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/5883dfe4-e2d4-423a-a6ec-1cbfd4918f86%40googlegroups.com.

webspher

unread,
Aug 24, 2016, 1:54:53 PM8/24/16
to mod-pagespeed-discuss
Thanks Jeff for your reply.

First of all, I'd like to ask you what is the equivalent of <IfModule pagespeed_module> in an .htaccess file ? i'll nee it to be able to work locally as i dont have pagespeed in my local machine!

What is the "$ cat mod_pagespeed_test/htaccess/.htaccess" for? i'm a little lost an confused :S

Jeff Kaufman

unread,
Aug 24, 2016, 2:24:44 PM8/24/16
to mod-pagespeed-discuss
On Wed, Aug 24, 2016 at 1:54 PM, webspher <red...@gmail.com> wrote:
>
> First of all, I'd like to ask you what is the equivalent of <IfModule
> pagespeed_module> in an .htaccess file ? i'll nee it to be able to work
> locally as i dont have pagespeed in my local machine!

In general, whatever configuration you'd put in your main server
config you can put in your .htaccess file, which includes <IfModule>
commands:

<IfModule pagespeed_module>
ModPagespeedDisallow *
</IfModule>

> What is the "$ cat mod_pagespeed_test/htaccess/.htaccess" for? i'm a little
> lost an confused :S

I was showing what command I ran. The "$" imitates a shell prompt and
indicates that what follows is a shell command. Running "cat
<filename>" prints our the contents of the file. So I was saying that
when I show the contents of my local file named
mod_pagespeed_test/htaccess/.htaccess I see:

ModPagespeedDisallow *

Jeff

webspher

unread,
Aug 24, 2016, 2:35:53 PM8/24/16
to mod-pagespeed-discuss
Ah OK, thank you very much Jeff for the explanations :)

I'll run some tests and will get back to you.

Cheers

webspher

unread,
Aug 25, 2016, 8:15:20 AM8/25/16
to mod-pagespeed-discuss
Hi,

I have just tried this: "ModPagespeedMapRewriteDomain cdn.domain.com domain.com" but the images and statis files are not being rewritten by pagespeed..., Am I missing something in the usage of ModPagespeedMapRewriteDomain ?

thanks

Jeff Kaufman

unread,
Aug 25, 2016, 9:46:44 AM8/25/16
to mod-pagespeed-discuss
Did you paste literally "cdn.domain.com domain.com" or did you
substitute your own cdn and site domain names?
> --
> 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/55a80f76-4370-4766-bc96-3de817028af3%40googlegroups.com.

webspher

unread,
Aug 25, 2016, 9:51:15 AM8/25/16
to mod-pagespeed-discuss
Of course i have replaced "domain" by our real domain name :)

Jeff Kaufman

unread,
Aug 25, 2016, 9:54:50 AM8/25/16
to mod-pagespeed-discuss
Sorry, just checking!

Is "domain.com" the url that resources have in your html?


On Thu, Aug 25, 2016 at 9:51 AM, webspher <red...@gmail.com> wrote:
> Of course i have replaced "domain" by our real domain name :)
>
> --
> 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/d25d0584-89bb-47e4-9e2a-530a46d3bd0e%40googlegroups.com.

webspher

unread,
Aug 25, 2016, 10:06:02 AM8/25/16
to mod-pagespeed-discuss
sorry for not being clear:
domain.com is our website from which all static files are displayed, and cdn.domain.com is a CNAME to our CDN provider (maxcdn) from which static files are cached and loaded.

Jeff Kaufman

unread,
Aug 25, 2016, 11:18:19 AM8/25/16
to mod-pagespeed-discuss
What domain do you have in your html? That's what PageSpeed needs to
make decisions based off of.
> --
> 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/4fbc0538-9257-4342-b544-e4f4933cfd9b%40googlegroups.com.

webspher

unread,
Aug 25, 2016, 11:29:48 AM8/25/16
to mod-pagespeed-discuss
in my html i have cdn.domain.com, for example:
<link rel="stylesheet" href="https://cdn.domain.com/css/styles.css" />
<img src="https://cdn.domain.com/img/image.png" height="40" width="150" alt="" />

webspher

unread,
Aug 25, 2016, 2:08:25 PM8/25/16
to mod-pagespeed-discuss
For info, this is what i'm using:
<IfModule pagespeed_module>
ModPagespeedEnableFilters rewrite_domains
ModPagespeedMapRewriteDomain cdn.domain.com domain.com
#ModPagespeedDomain cdn.domain.com
</IfModule>

I also tried to use only "ModPagespeedDomain" as mentioned in this page: https://developers.google.com/speed/pagespeed/module/domains but nothing happend and the name of static files don't change :(

Jeff Kaufman

unread,
Aug 25, 2016, 2:31:20 PM8/25/16
to mod-pagespeed-discuss
"ModPagespeedDomain cdn.domain.com" is what I was going to recommend,
since that's what you have in your html already.

Can you paste the headers that you get when you request
https://cdn.domain.com/img/image.png and
https://cdn.domain.com/css/styles.css ? I'm worried you might have a
header set that we treat as making it uncachable.

Jeff
> --
> 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/8c56598c-fb02-4559-af9c-7951856b7354%40googlegroups.com.

webspher

unread,
Aug 25, 2016, 4:55:14 PM8/25/16
to mod-pagespeed-discuss
here are the headers for the image:
  1. cache-control:
    max-age=300
  2. content-type:
    image/png
  3. date:
    Thu, 25 Aug 2016 20:51:07 GMT
  4. expires:
    Thu, 25 Aug 2016 20:56:07 GMT
  5. last-modified:
    Fri, 29 Jul 2016 20:27:20 GMT
  6. link:
    <https://www.domain.com/img/image.png>; rel="canonical"
  7. server:
    NetDNA-cache/2.2
  8. status:
    200
  9. x-cache:
    MISS
  10. x-content-type-options:
    nosniff

and for the css file:
  1. cache-control:
    max-age=300
  2. content-encoding:
    gzip
  3. content-type:
    text/css
  4. date:
    Thu, 25 Aug 2016 20:53:48 GMT
  5. etag:
    W/"PSA-aj-R3IL26VHr5"
  6. expires:
    Thu, 25 Aug 2016 20:58:48 GMT
  7. link:
    <https://www.domain.com/css/styles.css>; rel="canonical"
  8. server:
    NetDNA-cache/2.2
  9. status:
    200
  10. vary:
    Accept-Encoding
  11. x-cache:
    MISS
  12. x-content-type-options:
    nosniff
  13. x-original-content-length:
    2587


Message has been deleted

Jeff Kaufman

unread,
Aug 26, 2016, 11:00:01 AM8/26/16
to mod-pagespeed-discuss
Sorry, just looking at this now.

PageSpeed isn't optimizing the image, but it is optimizing the css
file in-place.

Can you give me the rest of the response headers? It looks like you
stripped out the HTTP status line among others?

On Fri, Aug 26, 2016 at 10:53 AM, webspher <red...@gmail.com> wrote:
> Hi Jeff,
>
> Was just wondering if you had a chance to look at the headers..
>
> Thanks
>
> --
> 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/a8a5a613-1869-4f0b-a177-6c25412d4d2a%40googlegroups.com.
Message has been deleted

Jeff Kaufman

unread,
Aug 26, 2016, 12:51:26 PM8/26/16
to mod-pagespeed-discuss
Looking at your main page, PageSpeed is optimizing the css files
actually hosted on your site:

/path/to/A.filename.css.pagespeed.cf.zr0A-EnpZc.css

When I load your page with '?PageSpeedFilters=+debug' I see, after the
resources listed on cdn.domain.com:

<!--The preceding resource was not rewritten because its domain
(cdn.domain.com) is not authorized-->

It sounds to me like your configuration to add "ModPageSpeedDomain
cdn.domain.com" didn't work, and PageSpeed is still acting as if it
doesn't have permission to rewrite resources on cdn.domain.com.

When you put other things in your .htaccess file, do they work? For example:

Header set X-Testing Test-Header

This should add an "X-Testing: Test-Header" to your headers, but my
guess is that it won't.

Do you have "AllowOverride None" anywhere in your Apache config? That
would keep .htaccess files from working. You can change that to
"AllowOverride All" to enable .htacess parsing.

Jeff

On Fri, Aug 26, 2016 at 11:21 AM, webspher <red...@gmail.com> wrote:
> Please don't be sorry, you're just helping and doing me a favor ;)
>
> so here are the direct links, and please let me know when you check the
> header so i can update the links to prevent them from being indexed :)
> https://cdn.optigura.com/img/sprite.png
> https://cdn.optigura.com/inc/css/global.css
>
> Once again, thanks a lot for your support
> cheers
>
> --
> 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/7c831674-f056-44fa-be8e-d22271a041e2%40googlegroups.com.
Message has been deleted

webspher

unread,
Aug 26, 2016, 7:01:39 PM8/26/16
to mod-pagespeed-discuss
I don't know what happened, my last message was deleted!!

Wow! "ModPagespeedMapRewriteDomain https://cdn.domain.com https://www.domain.com" seems to work well on optimizing css, js files and images :) its the "https" that was missing in the links that was causing the malfunctioning :) is it normal that the "https" must be in the URL ??
Should I consider this solved or is there anything else to consider?? :) 

However, i've noticed that some of the images are not being optimized: you can have a look at this url: domain.com/test/ (of course replace domain by our real domain name :))

cheers

webspher

unread,
Aug 27, 2016, 2:50:23 PM8/27/16
to mod-pagespeed-discuss
Hi again Jeff,

After running so many tests, i went through some issues and have some questions:

1- is it possible to optimize new images generated through ajax?

2- I'm using this:
## 1 YEAR
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>

## 1 MONTH
<FilesMatch "\.(jpg|jpeg|png|gif|txt|xml|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
but it doesn't seem to work well as some images have 300 max-age, is pagespeed changing the values?

3- since i'm using a cdn provider, is it worth using pagespeed cache?

4- sometimes when i change a .js file, the hash does't update and so it keeps the same version. what's the solution when it happens?

5- here is the config i'm using for pagespeed, do you thing something is missing or if I should remove any directives?

<IfModule pagespeed_module>
ModPagespeed on
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
ModPagespeedFileCachePath /var/cache/mod_pagespeed/

ModPagespeedLoadFromFile "https://www.domain.com/" "/path_to_root"
ModPagespeedLoadFromFile "https://www.domain.com/js/" "/path_to_js"
ModPagespeedLoadFromFile "https://www.domain.com/css/" "/path_to_css"
ModPagespeedLoadFromFile "https://www.domain.com/img/" "/path_to_images/"

ModPagespeedDisableFilters rewrite_images

ModPagespeedEnableFilters combine_css
ModPagespeedEnableFilters combine_javascript
ModPagespeedEnableFilters extend_cache
ModPagespeedEnableFilters rewrite_css
#ModPagespeedEnableFilters rewrite_images
ModPagespeedEnableFilters rewrite_javascript
ModPagespeedEnableFilters rewrite_style_attributes_with_url
ModPagespeedSharedMemoryLocks on

ModPagespeedUrlValuedAttribute img data-src image

ModPagespeedMessageBufferSize 100000
</IfModule>

Thanks a lot and have a great weekend ;)

Jeff Kaufman

unread,
Aug 29, 2016, 9:23:49 AM8/29/16
to mod-pagespeed-discuss
On Fri, Aug 26, 2016 at 7:01 PM, webspher <red...@gmail.com> wrote:
>
> Wow! "ModPagespeedMapRewriteDomain https://cdn.domain.com
> https://www.domain.com" seems to work well on optimizing css, js files and
> images :) its the "https" that was missing in the links that was causing the
> malfunctioning :) is it normal that the "https" must be in the URL ??
> Should I consider this solved or is there anything else to consider?? :)

Sorry, that's confusing! Yes, you do need to specify the https://,
because sites are allowed (by spec) to be completely different on http
and https. This means PageSpeed treats http://foo and https://foo as
completely independent domains.

>
> However, i've noticed that some of the images are not being optimized: you
> can have a look at this url: domain.com/test/ (of course replace domain by
> our real domain name :))

Looking at that url, the only images I see unoptimized are the ones in
the commented-out block.

(PageSpeed optimizes images in the background, so if you first visit a
page with new images they won't have been rewritten yet. But refresh
after a couple seconds and they should be.)

Jeff Kaufman

unread,
Aug 29, 2016, 9:33:28 AM8/29/16
to mod-pagespeed-discuss
On Sat, Aug 27, 2016 at 2:50 PM, webspher <red...@gmail.com> wrote:
>
> 1- is it possible to optimize new images generated through ajax?

To handle images that are loaded through ajax PageSpeed also rewrites
images in-place. This is on by default, so you should be seeing it
working. A way to tell is that images rewritten this way will have an
ETag like W/"PSA-aj-..."


> but it doesn't seem to work well as some images have 300 max-age, is
> pagespeed changing the values?

You have LoadFromFile enabled, PageSpeed doesn't see the cache-control
directives you have. Instead, set:

ModPagespeedLoadFromFileCacheTtlMs <cache_ttl_in_milliseconds>

See https://developers.google.com/speed/pagespeed/module/system#load_from_file_cache_ttl

> 3- since i'm using a cdn provider, is it worth using pagespeed cache?
>

I'm not sure what you mean by "pagespeed cache"? PageSpeed caches
it's optimizations internally automatically, which you do need, but we
don't have any sort of CDN. In general, PageSpeed makes sites with
CDNs work better, because it longcaches your resources.

> 4- sometimes when i change a .js file, the hash does't update and so it
> keeps the same version. what's the solution when it happens?

Is this a JS file you've asked PageSpeed to load from file?

Jeff

webspher

unread,
Aug 29, 2016, 2:45:37 PM8/29/16
to mod-pagespeed-discuss
Sorry, that's confusing!  Yes, you do need to specify the https://, 
because sites are allowed (by spec) to be completely different on http 
and https.  This means PageSpeed treats http://foo and https://foo as 
completely independent domains.

It's okay, it's good to know :)

 
Looking at that url, the only images I see unoptimized are the ones in 
the commented-out block. 

(PageSpeed optimizes images in the background, so if you first visit a 
page with new images they won't have been rewritten yet.  But refresh 
after a couple seconds and they should be.) 

Yes you're right, i had to refresh once or twice to see all images optimized


To handle images that are loaded through ajax PageSpeed also rewrites 
images in-place.  This is on by default, so you should be seeing it 
working.  A way to tell is that images rewritten this way will have an 
ETag like  W/"PSA-aj-..."
 
Actually this is not something working for me. if you go to any product page that has different sizes, and change the size, you'll see that images aren't optimized :/



You have LoadFromFile enabled, PageSpeed doesn't see the cache-control 
directives you have. Instead, set: 

    ModPagespeedLoadFromFileCacheTtlMs <cache_ttl_in_milliseconds> 

See https://developers.google.com/speed/pagespeed/module/system#load_from_file_cache_ttl 

when you say "Instead, set", do you mean i should replace "LoadFromFile" by "LoadFromFileCacheTtlMs"?


I'm not sure what you mean by "pagespeed cache"?  PageSpeed caches 
it's optimizations internally automatically, which you do need, but we 
don't have any sort of CDN.  In general, PageSpeed makes sites with 
CDNs work better, because it longcaches your resources. 

in other words, what i was trying to say, is if i still need to use "LoadFromFile"? and what will happen if I remove them?


Is this a JS file you've asked PageSpeed to load from file?

Sorry, didn't really understand what you mean! what file are you talking about? 


I'll have few other questions please:
5- I'm now using these new filter that I always thought they were On by default: remove_comments & collapse_whitespace. Is it possible to also remove the line breaks? I didn't find this filter

6- we use so many third party .js scripts (facebook, bing, google analytics), is there a way to optimize them?

Thanks a lot.

Jeff Kaufman

unread,
Aug 30, 2016, 9:10:10 AM8/30/16
to mod-pagespeed-discuss
On Mon, Aug 29, 2016 at 2:45 PM, webspher <red...@gmail.com> wrote:
>> To handle images that are loaded through ajax PageSpeed also rewrites
>> images in-place. This is on by default, so you should be seeing it
>> working. A way to tell is that images rewritten this way will have an
>> ETag like W/"PSA-aj-..."
>
>
> Actually this is not something working for me. if you go to any product page
> that has different sizes, and change the size, you'll see that images aren't
> optimized :/



>> You have LoadFromFile enabled, PageSpeed doesn't see the cache-control
>> directives you have. Instead, set:
>>
>> ModPagespeedLoadFromFileCacheTtlMs <cache_ttl_in_milliseconds>
>>
>> See
>> https://developers.google.com/speed/pagespeed/module/system#load_from_file_cache_ttl
>
> when you say "Instead, set", do you mean i should replace "LoadFromFile" by
> "LoadFromFileCacheTtlMs"?

Sorry, "instead" was the wrong word. In addition to LoadFromFile, you
should set LoadFromFileCacheTtlMs to indicate how long you want your
resources to be cached for at the browser.

>
>
>> I'm not sure what you mean by "pagespeed cache"? PageSpeed caches
>> it's optimizations internally automatically, which you do need, but we
>> don't have any sort of CDN. In general, PageSpeed makes sites with
>> CDNs work better, because it longcaches your resources.
>
> in other words, what i was trying to say, is if i still need to use
> "LoadFromFile"? and what will happen if I remove them?
>

PageSpeed is more efficient with LoadFromFile, because it can look
directly on your filesystem to find the resources, so if LoadFromFile
works for you then it's better to keep using it.

>
>> Is this a JS file you've asked PageSpeed to load from file?
>
> Sorry, didn't really understand what you mean! what file are you talking
> about?
>

Earlier you had written "4- sometimes when i change a .js file, the
hash does't update and so it keeps the same version. what's the
solution when it happens?"

I was wanting to know whether you had configured LoadFromFile to
include this JS file, or whether it was being loaded the default way
over HTTP.

>
> 5- I'm now using these new filter that I always thought they were On by
> default: remove_comments & collapse_whitespace. Is it possible to also
> remove the line breaks? I didn't find this filter

collapse_whitespace doesn't remove linebreaks because that can break
html. For example, consider:

<html>
this is a very long paragraph
that spans multiple lines
</html>

If you remove the linebreaks then you'll get the word "paragraphthat".

Even only removing linebreaks before tags isn't enough. Consider:

<html>
this is a very long <u>paragraph</u>
<i>that</i> spans multiple lines
</html>

Removing the linebreak gets you <u>paragraph</u><i>that<i> which is
run together into one word instead of being two.

>
> 6- we use so many third party .js scripts (facebook, bing, google
> analytics), is there a way to optimize them?
>

It's possible to pull them onto your domain to optimize with
MapProxyDomain, but we generally don't recommend this. The third
party scripts should already be optimized, and there's a good chance
that they're already in users browser caches. Bringing them onto your
site with MapProxyDomain doesn't allow sharing their cache entry
between multiple sites that all use, say, facebook's js.

Jeff

webspher

unread,
Aug 30, 2016, 2:28:30 PM8/30/16
to mod-pagespeed-discuss
Hi,

you quoted my previous phrase "Actually this is not something working for me. if you go to any product page that has different sizes, and change the size, you'll see that images aren't  optimized :/ " but you left it blank, maybe you have forgot to answer :)


Sorry, "instead" was the wrong word.  In addition to LoadFromFile, you 
should set LoadFromFileCacheTtlMs to indicate how long you want your 
resources to be cached for at the browser. 

OK, but than what is it for to add in the htaccess
<FilesMatch "\.(jpg|jpeg|png|gif|txt|xml|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
? isn't supposed to specify an expiry date for the mentionned files extension?

And how to specify an expiry date per file types using ModPagespeedLoadFromFileCacheTtlMs ?

Is there a way to check if the files was loaded through the filter "ModPagespeedLoadFromFile" ?


I was wanting to know whether you had configured LoadFromFile to 
include this JS file, or whether it was being loaded the default way 
over HTTP.

Ah OK, yes, this specific file is inside the js folder mentioned within "ModPagespeedLoadFromFile "https://www.domain.com/js/" "/path_to_js""


...... 
Removing the linebreak gets you <u>paragraph</u><i>that<i> which is 
run together into one word instead of being two.

You're right, but what about replacing the line break by a space? so
<html> 
this is a very long <u>paragraph</u> 
<i>that</i> spans multiple lines 
</html>
would be replaced by
<html> this is a very long <u>paragraph</u> <i>that</i> spans multiple lines </html>
 

It's possible to pull them onto your domain to optimize with 
MapProxyDomain, but we generally don't recommend this.  The third 
party scripts should already be optimized, and there's a good chance 
that they're already in users browser caches.  Bringing them onto your 
site with MapProxyDomain doesn't allow sharing their cache entry 
between multiple sites that all use, say, facebook's js.

OK, then i'll just try to reduce these external .js files. I asked because they all have 60seconds or few minutes of expiry cache which score very low in page speed insights...
I've seen somewhere that the google analytics .js file can be replaced directly with in a filter. do you recommend that practice?



I've seen in many examples combining filters but using different ModPagespeedEnableFilters, so what is the difference between
ModPagespeedEnableFilters remove_comments,rewrite_javascript,rewrite_css,rewrite_images

ModPagespeedEnableFilters elide_attributes,defer_javascript,move_css_to_head
and
ModPagespeedEnableFilters remove_comments,rewrite_javascript,rewrite_css,rewrite_images,elide_attributes,defer_javascript,move_css_to_head
??


Do you please have a link for an example of a good MPS config? i found this one but it seems to be outdated: https://github.com/danriti/bootstrap-pagespeed/issues/4


Long time ago I have reported a little bug for images that were resized for Retina displays, is it fixed?

Thanks again
Cheers
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages