Javascript: Is Javascript cached when called from the html body?

Problem!

I call the function JS

inside the html body section, the function parameters are collected by parsing EL

inside the function.

For example:

<script type="text/javascript">
    jQuery(window).load(function() {
        loadImage("${expression_language_var_1}", "${expression_language_var2}");
    });
</script>

      

But it seems that sometimes both parameters are cached and I am getting old information.

Questions!

  • Are script tags inside the html structure cached in the same way as external javascript files that are included in the header?

Regards,

+3


source to share


1 answer


The problem is the entire HTML page is cached including the script tags that contain your evaluated EL. If you are serving a page with the following headers, the browser should not cache it:

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

      



For more details on how these headers turn off caching refer to this answer: Using <meta> tags to turn off caching in all browsers?

+1


source







All Articles