Select to view content in your preferred language

Caching esri 4.0 js files

3434
7
Jump to solution
06-21-2016 03:47 AM
UdyWa
by
Deactivated User


Hi,

Is there a way we can cache required esri javascript files rather than loading them each time from server?

require(["esri/views/MapView"])

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Honored Contributor

The browser will handle caching the files for you. Once you load the CDN, it will just use the cache for every subsequent request. You can check this via the Chrome Developer tools, when you refresh a page, you'll see it comes (from cache).

cdn-cache.png

This is a benefit of using the CDN, as it will be cached across your applications.

View solution in original post

0 Kudos
7 Replies
DavidColey
Honored Contributor

Udy-

You have 2 choices: continue to reference the javascript modules via a cdn source or download and host the source on your webserver

David

0 Kudos
UdyWa
by
Deactivated User

The problem is, even if I downloaded the script files to local it still loaded from the server.

0 Kudos
DavidColey
Honored Contributor

Hmm, yeah I'm not seeing that. Sorry I don't know what to tell you . . .

0 Kudos
ReneRubalcava
Honored Contributor

The browser will handle caching the files for you. Once you load the CDN, it will just use the cache for every subsequent request. You can check this via the Chrome Developer tools, when you refresh a page, you'll see it comes (from cache).

cdn-cache.png

This is a benefit of using the CDN, as it will be cached across your applications.

0 Kudos
DavidColey
Honored Contributor

Hi Rene, correct me if I am wrong, but the browser should cache the .js files regardless of source. I think I misunderstood the original question.  I was thinking that the issue was with the CDN . . .

0 Kudos
ReneRubalcava
Honored Contributor

Maybe I worded it wrong. It will cache the files regardless of source, but it's a cache per domain. So whether they are hosted on your own server or via CDN, they'll get cached in the browser. I think we're saying the same thing though.

All I meant was that by using the CDN, like using the Google CDN for jQuery, is that it's now cached in your browser for all pages to use.

0 Kudos
DavidColey
Honored Contributor

Ah, cache per domain, yes.  Yes I think we're saying the same thing as well - - -

0 Kudos