Skip to content

Hello yale88. I'm curious about the HttpCacheInterceptor. #190

@jtm0609

Description

@jtm0609

Mobile: Samsung

Android OS: 10

NetWork: < WiFi

URL:

LIB Version: 2.1.8

Hi yale88, I'm analyzing your library. And then I got a question.
I attached the code below.

removeHeader("pragma").removeHeader("Cache-Control")

Can you tell me why you used this code?

class HttpCacheInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        String cache = request.header(WebViewCacheInterceptor.KEY_CACHE);
        Response originResponse = chain.proceed(request);
        if (!TextUtils.isEmpty(cache)&&cache.equals(CacheType.NORMAL.ordinal()+"")){
            return originResponse;
        }
        return originResponse.newBuilder().removeHeader("pragma").removeHeader("Cache-Control")
                .header("Cache-Control","max-age=3153600000").build();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions