0 Replies
      Latest reply on Jan 10, 2019 3:37 AM by t.s0114
      t.s0114 Level 1 Level 1 (0 points)



        I tried to execute http request using URLSession and related APIs as shown in the sequence below.

        Is it correct behavior that 2nd GET request gets response from cache?



        • Set URLCache with disk cache(50MB) and without memory cache to URLSession(configuration:).
        • All requests use "useProtocolCachePolicy"
        • All response sizes are less than 1KB



        1. Execute GET request
          • response is cached
        2. Execute POST/PUT/DELETE request for same url
          • response code is 200
        3. Execute GET request for same url
          • cache response is returned


        I expected 2nd GET request (3.) to return response from server since POST/PUT/DELETE request changes server resource.


        I have 2 questions.

        1. Does URLCache supports cache invalidation in case of POST/PUT/DELETE so that subsequent GET requests fetch latest response from server (This behavior is supported in frameworks like OkHttp).
        2. In case URLCache does not support above, how should I implement cache purge in case of POST/PUT/DELETE?