Just curious, whether the Google Maps API v3 javascript be cached on the local server?
Because, sometimes my intranet pages are loading slow because of slower internet connection. Otherwise, it would load the file from local server and slow down only when the map request is made.
I am even ready to run a cron job to update the javascript file once in a while.
Thanks for any input.
Customer must not use Google Maps Content from the Roads API in conjunction with a non-Google map. 6.4 Caching. Customer can temporarily cache latitude and longitude values from the Roads API for up to 30 consecutive calendar days, after which Customer must delete the cached latitude and longitude values.
The Maps JavaScript API uses a pay-as-you-go pricing model. Maps JavaScript API requests generate calls to two different SKUs depending on the type of request: map loads or panoramas.
Like many other Google web applications, Google Maps uses JavaScript extensively. The site also uses JSON for data transfer rather than XML, for performance reasons.
You get the equivalent of 200$ per month for free. The price of each request is stated here: https://cloud.google.com/maps-platform/pricing/. Once you have used 200$ worth of requests, you will have to start paying.
It's impossible "as is".
When you request the script from Google, they send headers along the script and those headers contains the "no-cache" directive.
So if you want them to be cachable, you must create a proxy. Instead of pointing the script src at Google, you point it to your server. Your server then make the call to Google and send the response back to the client.
This way you'll have control over the HTTP header and the caching. You could do caching on the script content as well to make less connections to Google.
I wouldn't advise someone to do it on a production or a mission critical website. All Google APIs are updated frequently and are bound more or less together. If something goes out of synch with something else, you have a hard to track bug on your hands.
Hope that helps.
EDIT: I heard you were putting your scripts in the HEAD
section of your document. Maybe thats hurting your "perceived" page loading time. Try to move the download of the script just before the </body>
tag and the map initialization in the onload
event of the page.
Mike
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With