As for the rules set HTTP-headers: use system-level caching network IOS. It is very simple to implement strategy. With the help of it you can significantly improve application performance.
They are, as we know, contained in each HTTP request or response. This is a set of metadata that are transmitted in the form of headers HTTP. All these metadata describe response / request MIME-type, several directives cache and status codes.
So, when the server receives a request from the client HTTP-response includes a set of headers HTTP, which serve as guidelines that the response should be cached. Cache-Control header must be present in the server response in order to sanction HTTP caching by the client. This title means the ability to include information in the form of maximum age. Section in RFC 2616 Cache-Control for more information.
And to the Supplement to Cache-Control server itself has the ability to send additional headers to use the required information:
Last-Modified is the value of the title and is the time / date as the requested resource was last modified. For example, if the client requests a chronology of recent photos value can be set at a time when the last photo was taken.
Etag - i.e. "entity tag" or ID that is the content of the requested resource. Practice shows Etag be something similar to MD5. This is important for dynamically generated resources. They can e have obvious Last-Modified value.
When a client has a response from any of their titles cache, their value can be forwarded to the following prompts: If-None-Match is a response header. During the early use Etag value obtained at the request of the client resource does not change. As for the If-Modified-Since - this title is fully consistent response header. If the resource is not updated after the last request, the server issues 304 - Not Modified.
In Web Cache-Control framework is announced quite easily. For example Ruby Sinatra provides some helper methods equivalents which can be compared to the header:
app.rb
Application class <Sinatra :: Base
get '/ founders do
# ...
cache_control: state,: must_revalidate,: max_age => 86400
last_modified Date.today
ETag Digest :: MD5.hexdigest (@ founders.to_s)
# ...
end
end
There is a large number of main browser toolbars. They allow us to see the headers received by API including Google Chrome and Firebug. Moreover, here you can watch the response and the request to the cache related zhagolovkov.
URL being embedded in the foundation class in the form of structures uses NSURLConnection SDURLCache AFNetworking and links to follow the directives sent from the HTTP server.
Heroku says CocoaPods was recommended as the preferred method for managing and Xcode type SDURLCache AFNetworking. Working with the IOS develops Sinatra API for more information. NSURLCache on automatic level has caching behavior of outgoing and incoming network requests. They also use NSURLConnection. If a cached response is available NSURLCache has a better return without a network request. Besides, SDURLCache is a subclass NSURLCache. It provides disk caching - it can persist across multiple application starts. But they are not available on NSURLCache mobile operating system. Thus, with a few tweaks to your IOS app will use a powerful infrastructure caching.