jQuery load function ignores Cache-Control max-age -


i using jquery's load function image (graph) server. graph received rest api protected basic authentication. image in current setup returned header cache-control max-age=0. respected if call image url directly browser. when using jquery's load function, cached.

i don't want new image every time, because requires heavy calculations on server, , because graphs shows real-time data, long time caching unwanted. use max-age=30 or 60 later.

i know jquery's ajax function has cache option. option can set true or false, , that's not i'm looking for.

the standard way override getting cached result append random query string url you're getting, in:

$(this).attr('src', url + '?randomval=' + (new date).gettime() ); 

you can set server headers allow client cache (e.g. cache-control: private - or whatever appropriate application), , decide in javascript code how want change "random" value appended url force resource reload.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -