1- Modify URL of
JavaScript or CSS resources by adding to it queryString with unique thing
that can not be duplicated like ("?"+Math.Random() ) or
("?" + new Date().getTime()")
so every time page
loaded , URL of resource will be appear for browser as a new URL so it will
made a new request to get copy of resource .
i made a JavaScript
function for loading script with feature option to enable caching or disabled
it
function loadJS(url,
options) {
var scriptElement = '<scr' + 'ipt src="' + url;
if (options != null
&& options.CachingEnabled != null &&
!options.CachingEnabled) {
scriptElement += '?' +
Math.random(); // or new Date().getTime()
}
scriptElement += '"
type="text/javascript"></scr' + 'ipt>';
document.write(scriptElement);
}
and then we can call it
like below
loadJS("env.js",
{ CachingEnabled: false });
references for this
solution:
Preventing
Cache on JavaScript files[stackoverflow]
2- I know you wont to
use jQuery but if you made any request to server that will made ajax call by
using jQuery ajax methods
and need to disable
caching on ajax requests it will apply prev solution with alternative thing
that supported from jQuery (property cach : false)
references for this
solution:
3- Disabling Caching
with .htaccess file that will be supported with Apache server
<filesMatch "\.(js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>
references for this solution :
htaccess file no cache
Disabling Caching with .htaccess