We all know adding a far-future expiration date to static resources is a good practice to increase our websites' page load speed. So we've ensured it for all of our resources BUT the all-too-common Facebook JS SDK and Google Analytics don't do that and thus lower the entire page's speed score.
Examining the headers shows Facebook do 20 minutes: Cache-Control public, max-age=1200 Connection keep-alive Content-Type application/x-javascript; charset=utf-8 Date Tue, 23 Sep 2014 04:46:38 GMT Etag "566aa5d57a352e6f298ac52e73344fdc" Expires Tue, 23 Sep 2014 05:06:38 GMT
and Google Analytics do 2 hours: Key Value Response HTTP/1.1 200 OK Date Tue, 23 Sep 2014 04:45:49 GMT Expires Tue, 23 Sep 2014 06:45:49 GMT Last-Modified Mon, 08 Sep 2014 18:50:13 GMT X-Content-Type-Options nosniff Content-Type text/javascript Server Golfe2 Age 1390 Cache-Control public, max-age=7200 Alternate-Protocol 80:quic,p=0.002 Content-Length 16,062
Is there a way to force them to longer expiration dates?
The solution finally implemented was to move to Facebook's rediret API which doesn't force loading their script on each page load. It's actually what StackOverflow does here as well. Start a session in a private/incognito browser and you'll see. This link might help: https://developers.facebook.com/docs/php/howto/example_facebook_login