3

https://developers.google.com/speed/pagespeed/module/ This link doesn't talk specifically about CSS and js auto versioning but I read somewhere that this module can be used for auto versioning of CSS and js files. Would like to confirm about this.

Please let me know if auto versioning is part of google's mod_pagespeed module and if it can be used with my Apache tomcat 8 server ?

Any references to the above functionality will be greatly appreciated.

Kara
  • 6,115
  • 16
  • 50
  • 57
manohar_tn
  • 101
  • 1
  • 10
  • 2
    read the first paragraph: https://developers.google.com/speed/pagespeed/module/restricting_urls – dandavis Jun 23 '15 at 21:01
  • 1
    @dandavis: Not sure what *"By default, all HTML files served by your server and all resources (CSS, images, JavaScript) found in HTML files whose origin matches the HTML file, or whose origin is authorized via Domain, will be rewritten. However, this can be restricted by using wildcards, using the directives:"* has to say about auto-versioning...? – T.J. Crowder Jul 16 '15 at 07:14
  • 1
    it says it rewrites css, images, and js, OP asked about 2 of those 3... the question itself is weird since versioning static content to use long-lasting (perma-cached) URLs is the main thing pagespeed does. – dandavis Jul 16 '15 at 07:37
  • 1
    I'm with TJ. I don't see what rewriting (minifying) has to do with auto-versioning. – joe Apr 02 '16 at 05:08
  • I also heard that this mod deals with auto versioning. I can understand @dandavis saying that it rewrites it and it uses a md5 hash for long caching but I'm not sure that this auto versions in the sense that when it is updated it will reversion the file. I'm going to do some tests and I will see if I can find out – doz87 Dec 21 '16 at 04:27

1 Answers1

1

I have done some testing and from what I can see, the answer is no, well at least no in the sense that it won't auto version immediately after a change.

For reference, I'm running Apache 2.4.10.

From my tests, I had 4 javascript files that I was monitoring, these files were being optimised by pagespeed and the resulting file had a hash of ...pagespeed.jc.bFZBaW2xkN.js.

Within this file, it also gives hashes for each file it combines.

var mod_pagespeed_64gxmrG5cP = ...
var mod_pagespeed_r8BXvaG1ZV = ...
var mod_pagespeed_86DySW9yKu = ...
var mod_pagespeed_FAqlx5ADkk = ...

I found that I would make changes to files but nothing would change until I did a hard refresh (using Chrome).

When hard refreshing, I noticed the main file name ...pagespeed.jc.bFZBaW2xkN.js hash would update and looking within the file showed the change but that the inner hashes that represented the combined file were still the same.

I ended up implementing my own auto versioning in a php function that just appends the file modified time to the end of the file as a query eg. somejavascriptfile.js?v=0123456789

Now if I touch the file, the main combined file updates its hash but the inner hashes also update.

Hope this helps anyone else out there wondering the same thing.

doz87
  • 591
  • 6
  • 15