• Google page speed indicates I should leverage browser caching for google maps.

    Consider Fixing:
    Leverage browser caching
    Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.

    Leverage browser caching for the following cacheable resources:
    https://maps.google.com/maps/api/js?sensor=false (30 minutes)

    Can I manually add code to .htaccess file and if so, recommended code to add?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try this sample code in your .htaccess file. Be sure to back that file up or make a copy before replacing it with this code. Add this code at the top of the file. Note also that this code is for almost every type of asset on your site (e.g. images, css, js, etc.).

    <IfModule mod_expires.c>
    # Enable expirations
    ExpiresActive On
    # My favicon
    ExpiresByType image/x-icon "access plus 1 year"
    # Images
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    # CSS
    ExpiresByType text/css "access plus 1 month"
    # Javascript
    ExpiresByType application/javascript "access plus 30 minutes"
    </IfModule>

    This code will cache the assets for around 30 days. Except for the javascript which should only be cached for 30 minutes.

    Hopefully Google Pagespeed likes this.

    You can’t control what 3rd party sites do, such as the stuff at maps.google.com. You can only affect what your blog’s own webserver sends to the client.

    It’s possible that Google does not set that specific script to be cached on purpose.

    @markrh thanks for catching that I didn’t even notice that it was a Google Maps link.

    it does raise the question as to why Google Pagespeed even flags its own sites. I guess if nothing else you can get the information on what is causing slow page load times.

    Thread Starter rainman50

    (@rainman50)

    Thanks for the replies. I’ll post an update with new info.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Leverage browser caching’ is closed to new replies.