Leverage browser caching for Facebook, Google+, or other 3rd party resource files

26,085

Solution 1

You have no control over them because they are hosted by another provider. And honestly speaking you should not worry about them, it's up to Google, Facebook, etc to handle the caching accordingly to their need.

You could potentially proxy the URLs or download the files locally, but I don't encourage you to follow that route. In fact, you may potentially end up with a configuration that do not reflect the changes when the upstream provider publish an update, or simply conflict with the caching already applied by Google, Facebook, etc.

Solution 2

You should consider removing third party JavaScript from Facebook and Google from your pages. The only third party JavaScript I typically have is for advertising.

All of the social networks have ways that you can use plain links (no JavaScript) to share your page. See this question on StackOverflow. You wouldn't be able to see stats for likes and +1 in the page though.

Share:
26,085

Related videos on Youtube

user3134277
Author by

user3134277

Updated on September 18, 2022

Comments

  • user3134277
    user3134277 over 1 year

    I tested my website with Google PageSpeed Insights.

    I did cache optimization in my .htaccess, but it didn't affect resource files that are from Facebook and Google+

    Leverage browser caching
    
        http://connect.facebook.net/fr_FR/all.js (20 minutes)
    
        https://apis.google.com/js/plusone.js (30 minutes)
    
        https://oauth.googleusercontent.com/…e:rpc:shindig.random:shindig.sha1.js?c=2 (60 minutes)
    

    What can I do to solve this?

  • Kenzo
    Kenzo over 10 years
    But that doesn't help when getting to cases such as loading third party JQuery libraries. Simone Carletti's answer would apply here.
  • Stephen Ostermiller
    Stephen Ostermiller over 7 years
    Welcome to this site. I've edited this answer quite heavily because it did not meet our quality standards. You had included a link to your own site. That can be fine if it is needed to answer the question, but in this case it was not needed. Your grammar and formatting needed many improvements. I also removed the profanity which is not appropriate here.
  • andrew
    andrew over 7 years
    and if you absolutely must have these scripts, make them load asynchronous, after main page load is completed.
  • Martijn
    Martijn over 7 years
    Wonderful that it's up to Google and FB, but I want my site to be faster. I can't control my site regarding this.
  • fregante
    fregante over 7 years
    You're using their services, probably for free, so it's unfortunately up to them.