Retrofit: el control de caché nunca se incluyó en la respuesta
no importa lo que haga, nunca puedo ver el encabezadocontrol de caché en la respuesta
Configuraciones
actualización 1.6.0okHttp 1.6.0okHttp-urlConnection 1.6.0gson 2.2.4Android 4.0+1. Configuración
1.1 RestAdapter con mi OkHttpClient
OkHttpClient okHttpClient = new OkHttpClient();
Cache cache = new Cache(getCacheDir(), 1024);
okHttpClient.setCache(cache);
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(URL)
.setClient(new OkClient(okHttpClient))
.setLogLevel(LogLevel.HEADERS)
.build();
1.2 RestAdapter con el OkHttpClient predeterminado Aquí, al depurar, pude ver que el cliente tienecaché = nulo;
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(URL)
.setLogLevel(LogLevel.HEADERS)
.build();
2 registro
Para ambas configuraciones, los registros son los mismos.
2.1 SOLICITUD
06-28 13: 24: 05.601: D / Retrofit (1581): ---> HTTP GET myUri
06-28 13: 24: 05.601: D / Retrofit (1581): Control de caché: público, edad máxima = 640000
06-28 13: 24: 05.601: D / Retrofit (1581): ---> FIN HTTP (sin cuerpo)
2.2 RESPUESTA
06-28 13: 24: 05.701: D / Retrofit (1581): <--- HTTP 200 myUri (102ms)
06-28 13: 24: 05.701: D / Retrofit (1581):: HTTP / 1.1 200 OK
06-28 13: 24: 05.701: D / Retrofit (1581): Conexión: mantener vivo
06-28 13: 24: 05.701: D / Retrofit (1581): Tipo de contenido: texto / html
06-28 13: 24: 05.701: D / Retrofit (1581): Fecha: sábado 28 de junio de 2014 13:24:01 GMT
06-28 13: 24: 05.701: D / Retrofit (1581): OkHttp-Received-Millis: 1403961845708
06-28 13: 24: 05.701: D / Retrofit (1581): OkHttp-Response-Source: NETWORK 200
06-28 13: 24: 05.701: D / Retrofit (1581): OkHttp-Sent-Millis: 1403961845680
28/06 13: 24: 05.701: D / Retrofit (1581): Servidor: nginx / 1.6.0
06-28 13: 24: 05.701: D / Retrofit (1581): Codificación de transferencia: fragmentada
06-28 13: 24: 05.701: D / Retrofit (1581): Variar: Aceptar-Codificar
06-28 13: 24: 05.701: D / Retrofit (1581): X-Powered-By: PHP / 5.5.12-1 ~ dotdeb.1
06-28 13: 24: 05.701: D / Retrofit (1581): <--- END HTTP (cuerpo de -1 byte)
EDITAR 07/03/2014
Me di cuenta de que en esta preguntaRetrofit + OkHttp está bien al enviar solicitudes GET pero da SocketTimetout al enviar POST el autor de la pregunta obtiene "control de caché" en respuesta.
04-11 18: 00: 41.291: D / Retrofit (16390): ---> URL HTTP GET
04-11 18: 00: 41.291: D / Retrofit (16390): ---> END HTTP (cuerpo de 0 bytes)
04-11 18: 00: 42.008: D / Retrofit (16390): <--- HTTP 200 url (716ms)
04-11 18: 00: 42.015: D / Retrofit (16390):: HTTP / 1.1 200 OK
04-11 18: 00: 42.015: D / Retrofit (16390): Cache-Control: max-age = 0, privado, debe revalidar
Sin embargo, todavía no puedo resolver este problema ni en emuladores ni en un dispositivo real ...