Skip to content

Cache key doesn't include method (only URL) #154

@r-cohen

Description

@r-cohen

Hi.
I'm looking how the default getCacheKey() method for requests is by default returning only the URL. I have noticed that in the previous repository I was using (mcxiaoke) they decided to include the method along with the URL by default:
https://github.com/mcxiaoke/android-volley/blob/7d0c11b73c17ff81d1b7f4f128bfa9ef997ae62c/src/main/java/com/android/volley/Request.java#L315

Stumbled into this because my server responds differently for the same URL whether my method is GET or POST, and with the current caching volley gives me the same answer (but shouldn't). I perfectly know I can disable the cache or implement my own cache key.

Nevertheless, looking at the RFC here:
https://tools.ietf.org/html/rfc7234#page-6
I state:
The primary cache key consists of the request method and target URI. However, since HTTP caches in common use today are typically limited to caching responses to GET, many caches simply decline other methods and use only the URI as the primary cache key.

I interpreted as: the method should be included in the cache key, or the cache should be enabled by default only for GET methods. But clearly not: the cache should be enabled by default for the same URL and for different methods, unless I am mistaken?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions