{"id":5215,"date":"2019-03-20T12:36:44","date_gmt":"2019-03-20T07:06:44","guid":{"rendered":"https:\/\/www.innovationm.com\/blog\/?p=5215"},"modified":"2019-03-20T15:03:10","modified_gmt":"2019-03-20T09:33:10","slug":"offline-content-storage-and-sync-with-server-when-modified","status":"publish","type":"post","link":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/","title":{"rendered":"Offline Content Storage and Sync with Server when Modified"},"content":{"rendered":"<h3>What is If-Modified-Since?<\/h3>\n<ul>\n<li>The smart and efficient way to get images, icons and more from your server.<\/li>\n<li>If-Modified-Since is an HTTP header Which is sent to the server as a condition.<\/li>\n<li>If the content has been changed on the server, then the server responds with 200 status code with the whole requested document.<\/li>\n<li>Else If the content is not changed on the server, the server responds with a status code 304.<\/li>\n<\/ul>\n<h3>How it works?<\/h3>\n<ul>\n<li>When our conditional get request is made by the client to the server for a particular source, the client will provide if modified since header with the Last-Modified date of its cached copy.<\/li>\n<li>On the basis of If-Modified-Since header server determines if requested client\u2019s cached copy is the most updated or not.<\/li>\n<li>If yes, then the server responds client an HTTP status code 304 i.e client can reuse its cached file.<\/li>\n<li>If the client does not have a cached copy (i.e it is the first time visiting the resource), the resource must be downloaded from the origin server, resulting in an HTTP code 200. Similarly, this code will also be returned for requests that have an outdated version of a resource stored in cache thus requiring the latest resource to be fetched from the server.<\/li>\n<\/ul>\n<h3>How to implement in your code?<\/h3>\n<ol>\n<li>check if data updated on server or not.<\/li>\n<li>pass If-Modified-Since header with time client first downloaded a resource from the server.<\/li>\n<li>get response code from the server.<\/li>\n<li>if the response code is 200, means data is updated, get data from server and store locally.<br \/>\nAlso, store last modified time value from header field i.e Last-Modified, this value is passed further in If-Modified-Since header.<\/li>\n<li>else if the response code is 304, get data from your local storage.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is If-Modified-Since? The smart and efficient way to get images, icons and more from your server. If-Modified-Since is an HTTP header Which is sent to the server as a condition. If the content has been changed on the server, then the server responds with 200 status code with the whole requested document. Else If [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5221,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,108,3,71,102],"tags":[336,335],"class_list":["post-5215","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-html5-css-js","category-ios","category-mobile","category-web-service","tag-googlebot","tag-http-headers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Offline Content Storage and Sync with Server when Modified - InnovationM - Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Offline Content Storage and Sync with Server when Modified - InnovationM - Blog\" \/>\n<meta property=\"og:description\" content=\"What is If-Modified-Since? The smart and efficient way to get images, icons and more from your server. If-Modified-Since is an HTTP header Which is sent to the server as a condition. If the content has been changed on the server, then the server responds with 200 status code with the whole requested document. Else If [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/\" \/>\n<meta property=\"og:site_name\" content=\"InnovationM - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-20T07:06:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-20T09:33:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2019\/03\/if-modified.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1161\" \/>\n\t<meta property=\"og:image:height\" content=\"649\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"InnovationM Admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InnovationM Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/\"},\"author\":{\"name\":\"InnovationM Admin\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"headline\":\"Offline Content Storage and Sync with Server when Modified\",\"datePublished\":\"2019-03-20T07:06:44+00:00\",\"dateModified\":\"2019-03-20T09:33:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/\"},\"wordCount\":299,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/if-modified.png\",\"keywords\":[\"googleBot\",\"HTTP headers\"],\"articleSection\":[\"Android\",\"HTML5 \\\/ CSS \\\/ JS\",\"iOS\",\"Mobile\",\"Web service\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/\",\"name\":\"Offline Content Storage and Sync with Server when Modified - InnovationM - Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/if-modified.png\",\"datePublished\":\"2019-03-20T07:06:44+00:00\",\"dateModified\":\"2019-03-20T09:33:10+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/if-modified.png\",\"contentUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/if-modified.png\",\"width\":1161,\"height\":649},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/offline-content-storage-and-sync-with-server-when-modified\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Offline Content Storage and Sync with Server when Modified\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\",\"name\":\"InnovationM - Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\",\"name\":\"InnovationM Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"caption\":\"InnovationM Admin\"},\"sameAs\":[\"http:\\\/\\\/www.innovationm.com\\\/\"],\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/author\\\/innovationmadmin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Offline Content Storage and Sync with Server when Modified - InnovationM - Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/","og_locale":"en_US","og_type":"article","og_title":"Offline Content Storage and Sync with Server when Modified - InnovationM - Blog","og_description":"What is If-Modified-Since? The smart and efficient way to get images, icons and more from your server. If-Modified-Since is an HTTP header Which is sent to the server as a condition. If the content has been changed on the server, then the server responds with 200 status code with the whole requested document. Else If [&hellip;]","og_url":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/","og_site_name":"InnovationM - Blog","article_published_time":"2019-03-20T07:06:44+00:00","article_modified_time":"2019-03-20T09:33:10+00:00","og_image":[{"width":1161,"height":649,"url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2019\/03\/if-modified.png","type":"image\/png"}],"author":"InnovationM Admin","twitter_misc":{"Written by":"InnovationM Admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/#article","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/"},"author":{"name":"InnovationM Admin","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"headline":"Offline Content Storage and Sync with Server when Modified","datePublished":"2019-03-20T07:06:44+00:00","dateModified":"2019-03-20T09:33:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/"},"wordCount":299,"commentCount":0,"image":{"@id":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2019\/03\/if-modified.png","keywords":["googleBot","HTTP headers"],"articleSection":["Android","HTML5 \/ CSS \/ JS","iOS","Mobile","Web service"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/","url":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/","name":"Offline Content Storage and Sync with Server when Modified - InnovationM - Blog","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/#primaryimage"},"image":{"@id":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2019\/03\/if-modified.png","datePublished":"2019-03-20T07:06:44+00:00","dateModified":"2019-03-20T09:33:10+00:00","author":{"@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"breadcrumb":{"@id":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/#primaryimage","url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2019\/03\/if-modified.png","contentUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2019\/03\/if-modified.png","width":1161,"height":649},{"@type":"BreadcrumbList","@id":"https:\/\/www.innovationm.com\/blog\/offline-content-storage-and-sync-with-server-when-modified\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.innovationm.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Offline Content Storage and Sync with Server when Modified"}]},{"@type":"WebSite","@id":"https:\/\/www.innovationm.com\/blog\/#website","url":"https:\/\/www.innovationm.com\/blog\/","name":"InnovationM - Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.innovationm.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed","name":"InnovationM Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","caption":"InnovationM Admin"},"sameAs":["http:\/\/www.innovationm.com\/"],"url":"https:\/\/www.innovationm.com\/blog\/author\/innovationmadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/5215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/comments?post=5215"}],"version-history":[{"count":0,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/5215\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media\/5221"}],"wp:attachment":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media?parent=5215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/categories?post=5215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/tags?post=5215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}