ACTUALIZACIÓN
lo hice un poco más de investigación del problema y se puede encontrar más información detallada answer in my recent post Nota, la solución se describe a continuación (en principio) no es la solución navegadores.
No estoy seguro de si ayuda, pero puede intentar el siguiente truco: 1. Agregue un recurso a su página, digamos que será el archivo de Javascript cachedetect.js
. 2. El servidor debe generar cachedetect.js
cada vez que alguien lo solicite. Y debe contener encabezados relacionados con caché en respuesta, es decir, si el caché del navegador está habilitado, el recurso debe almacenarse en caché durante mucho tiempo. Cada cachedetect.js
debería tener este aspecto:
var version = [incrementally generated number here];
var cacheEnabled; //will contain the result of our check
var cloneCallback;//function which will compare versions from two javascript files
function isCacheEnabled(){
if(!window.cloneCallback){
var currentVersion = version;//cache current version of the file
// request the same cachedetect.js by adding <script> tag dynamically to <header>
var head = document.getElementsByTagName("head")[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "cachedetect.js";
// newly loaded cachedetect.js will execute the same function isCacheEnabled, so we need to prevent it from loading the script for third time by checking for cloneCallback existence
cloneCallback = function(){
// once file will be loaded, version variable will contain different from currentVersion value in case when cache is disabled
window.cacheEnabled = currentVersion == window.version;
};
head.appendChild(script);
} else {
window.cloneCallback();
}
}
isCacheEnabled();
Después de que usted puede simplemente comprobar si hay cacheEnabled === true
o cacheEnabled === false
después de un cierto período de tiempo.
Lo ¿Quiere decir al tiempo que dice "el navegador está optimizado para el almacenamiento en caché"? ¿Admite etag o algún encabezado de caché específico? –
Puede deshabilitar el almacenamiento de archivos estáticos en la configuración del navegador. ¿Hay alguna manera de probar si ese almacenamiento está deshabilitado? – gaffleck