last day (14 days later) » 

9:18 AM
0
Q: Cache policy in Parse.com service

alexI know that cache policy can be set if we are using queries in Parse.com service (Ex:) ParseQuery query = new ParseQuery("Players"); query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE); but how to do it if i use only Parse's Rest API? Object's model + network layer inside the ...

 
The caching is on the client side. If you are using the REST api directly, you will have to implement your own caching solution.
 
query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE); for exanmple changes HTTPHeaders in server's response. I need a way to change server's response headers in order to allow caching. AFHttpNetworkig for iOS can work with cache, but it needs propers headers filelds
 
Have you tried setting Cache-Control headers in your request?
 
Hm, no.Now I'm getting "Cache-Control" = "max-age=0, private, must-revalidate"; What will be the correct header, that will tell the server , that caching i want it to allow caching?
 
Not sure, you'll have to experiment. Try setting max-age with a non-zero value, and see what you get back.
My understanding of the caching directive though is that it controls the caching behavior of the server not the client. The query.setCachePolicy on the other hand modifies the caching behavior on the client.
 
9:18 AM
No, setting any cache-control value in request doesn't influence response headers values.
 
To be clear, what are you trying to achieve?
 
9:41 AM
oh
i didn't know about the chat)
So, I would like to cache get responses in order to provide cached information to user when there is no internet connection
I am using AFNetworking library that supports caching
i overrides it's method - (void)URLSession:(NSURLSession *)session
dataTask:(NSURLSessionDataTask *)dataTask
willCacheResponse:(NSCachedURLResponse *)proposedResponse
completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler
but it is never called
i decided that the reason is-that server doesn't allow to clients to cache responces
As docs say:"The delegate receives connection:willCacheResponse: messages only for protocols that support caching." so, as i receive Cache-control: max-age:0 looks like server doesn't support aching by default
am I right?
 
10:08 AM
very possible
just out of curiosity, why are you not using the iOS SDK?
again, I think you are confusing server-side caching with client-side caching
as per my answer
 
do you mean iOS SDK from parse?
 
just because parse i am using as temporary solution while backend in my company will be ready
that's why i get json from parse and than transform to my custom objects objects
as soon as backend is ready - all i need, just change api link
i parse admin panel I created objects with proper fields so they look like real objects i will have in future
 
i see
well i think you are out of luck in terms of manipulating the cache-control directives of the parse servers
 
i also think so
anyway
thanks for help
 
10:21 AM
no problem
 

last day (14 days later) »