Borrar caché de NSURLConnection


¿Hay alguna forma de borrar la caché de NSURLConnection?

Lo usé para descargar algunas cadenas, pero sigo recibiendo las mismas cadenas a pesar de que cambié eso desde mi servidor.

Author: Vadim Kotov, 2011-10-27

5 answers

Puede borrar la caché explícitamente usando:

Obj-c

[[NSURLCache sharedURLCache] removeAllCachedResponses];

Swift

 URLCache.shared.removeAllCachedResponses()
 60
Author: Ben-G,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-11 11:38:29

Se especifica la política de caché cuando se crea el objeto NSURLRequest. Establezca la propiedad cachePolicy en NSURLRequestReloadIgnoringCacheData o use el inicializador initWithURL:cachePolicy:timeoutInterval:. Consulte documentación sobre la política de caché.

 14
Author: Robin Summerhill,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-10-26 20:59:58

Agregue un número aleatorio al final del nombre del archivo

Como abc.pdf?rand=10023

 2
Author: Bejoy Balan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-01-22 11:41:17

Aquí hay una manera de las páginas oficiales de Apple que podría ayudar. Simplemente lea la respuesta breve e informativa en el enlace.

Caché de Sesión TLS

 0
Author: Husyn,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-07-13 13:28:27

Tuve el mismo problema, no importa lo que haga, seguiré recibiendo datos antiguos de la web. Hice una solución simple. Hice un script php. Este script lee los datos . ahora tengo acceso a este script php en lugar del archivo de datos y estoy listo para ir.

 -4
Author: vikram mehta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-03-04 14:46:29