{"id":36,"date":"2008-06-21T16:12:20","date_gmt":"2008-06-21T08:12:20","guid":{"rendered":"http:\/\/blog.lolyco.com\/sean\/?p=36"},"modified":"2008-06-21T23:14:16","modified_gmt":"2008-06-21T15:14:16","slug":"if-modified-since-date-formats-in-firefox-and-ie7","status":"publish","type":"post","link":"https:\/\/blog.lolyco.com\/sean\/2008\/06\/21\/if-modified-since-date-formats-in-firefox-and-ie7\/","title":{"rendered":"If-Modified-Since date formats in Firefox and IE7"},"content":{"rendered":"<p><strong>Everybody<\/strong> who has a webserver <strong>wants to use less bandwidth<\/strong>. A <strong>webserver<\/strong> sends out a lot of copies of the <strong>same information<\/strong>. Stylesheets, images, static HTML pages, javascript files. Many of these <strong>rarely<\/strong>, if ever,\u00a0 <strong>change<\/strong> from one visit by a browser to the next. <strong>Fortunately<\/strong>, there are a few schemes implemented in <strong>HTTP<\/strong> that help <strong>save bandwidth<\/strong>.<\/p>\n<p>I&#8217;ve been <strong>writing<\/strong> a webserver recently, so I&#8217;ve become more acquainted with HTTP <strong>features<\/strong> than I might ever have wanted to. Don&#8217;t ask me <strong>why<\/strong> I&#8217;m writing a webserver, I&#8217;m beginning to <strong>wonder<\/strong> myself. It seemed like a <strong>good idea<\/strong> at the time I started it.<\/p>\n<p><a title=\"Apache.org\" href=\"http:\/\/www.apache.org\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" border=\"0\" class=\"alignright size-full wp-image-41\" style=\"margin-left: 8px; margin-right: 8px;\" title=\"apache_160\" src=\"http:\/\/blog.lolyco.com\/sean\/wp-content\/uploads\/2008\/06\/apache_160.gif\" alt=\"Apache foundation\" width=\"160\" height=\"48\" \/><\/a>When I first started watching <a title=\"Apache.org\" href=\"http:\/\/www.apache.org\" target=\"_blank\"><strong>Apache<\/strong><\/a> access <strong>logs<\/strong> (this is a kind of <strong>mental illness<\/strong>, I can&#8217;t recommend it), I noticed <strong>304<\/strong> responses for some popular files. HTTP 304 is &#8216;<a title=\"HTTP 304 at w3.org\" href=\"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html#sec10.3.5\" target=\"_blank\"><strong>Not Modified<\/strong><\/a>&#8216;. Most browsers <strong>cache<\/strong> files they download from webservers, and don&#8217;t <strong>download<\/strong> them again if they haven&#8217;t changed. The way they do this is by <strong>conditionally<\/strong> fetching content from the webserver.<\/p>\n<p><a href=\"http:\/\/www.spreadfirefox.com\/node&amp;id=239108&amp;t=315\"><img decoding=\"async\" class=\"alignright\" style=\"float: right;\" title=\"Firefox 3\" src=\"http:\/\/sfx-images.mozilla.org\/affiliates\/Buttons\/firefox3\/FF3_88x31_g.png\" border=\"0\" alt=\"Firefox 3\" \/><\/a><a title=\"Mozilla Firefox\" href=\"http:\/\/www.mozilla-europe.org\/en\/firefox\/\" target=\"_blank\"><strong>Firefox<\/strong><\/a> had a super handy extension called &#8216;<strong>LiveHTTPHeaders<\/strong>&#8216; that allows you to see exactly what <strong>messages<\/strong> your browser exchanges with the web server. Even if you don&#8217;t have a direct use for it, the <strong>conversations<\/strong> between your browser and web servers can <strong>tell you a lot<\/strong> about how <a title=\"Epiphany at gnome.org\" href=\"http:\/\/www.gnome.org\/projects\/epiphany\/\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" border=\"0\" class=\"alignleft\" style=\"float: left; margin-left: 5px; margin-right: 5px;\" src=\"http:\/\/www.gnome.org\/projects\/epiphany\/images\/epiphany-64.png\" alt=\"Gnome's epiphany\" width=\"64\" height=\"64\" \/><\/a>the Web works. Last time I looked, this extension <strong>wasn&#8217;t available<\/strong> in Firefox 3. <a title=\"Epiphany at gnome.org\" href=\"http:\/\/www.gnome.org\/projects\/epiphany\/\" target=\"_blank\"><strong>Epiphany<\/strong><\/a> has something very similar, so I&#8217;ve been using that browser while I&#8217;m <strong>developing<\/strong> my webserver.<a href=\"http:\/\/blog.lolyco.com\/sean\/wp-content\/uploads\/2008\/06\/wireshark_120.jpeg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-42\" style=\"border: 0pt none; float: right; margin-left: 8px; margin-right: 8px;\" title=\"wireshark_120\" src=\"http:\/\/blog.lolyco.com\/sean\/wp-content\/uploads\/2008\/06\/wireshark_120.jpeg\" alt=\"Wireshark\" width=\"120\" height=\"39\" \/><\/a> You can read the HTTP conversations by using a tool like <strong><a title=\"WireShark.org\" href=\"http:\/\/www.wireshark.org\/\" target=\"_blank\">WireShark<\/a><\/strong> too, a very <strong>powerful<\/strong> and complex network analysis <strong>tool<\/strong>.<\/p>\n<p>A browser makes a conditional request from a webserver when it has an <strong>earlier copy<\/strong> of the object in its cache. To <strong>avoid<\/strong> the possibility of presenting <strong>out-of-date content<\/strong> to the user, the browser sends an &#8216;<strong><a title=\"If-Modified-Since at w3.org\" href=\"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec14.html#sec14.25\" target=\"_blank\">If-Modified-Since<\/a><\/strong>&#8216; header field, with the date the browser last downloaded the content. The Webserver checks this date against the date the content was <strong>last changed<\/strong> on the server. If the server content has changed, the content is <strong>sent as normal<\/strong>. If the content has not changed since the browser last downloaded it, the server makes a &#8216;304 Not Modified&#8217; <strong>response<\/strong>, and the browser uses the cached <strong>content<\/strong>.<\/p>\n<p><a href=\"http:\/\/java.com\/java\/download\/index.jsp?cid=jdp129956\" target=\"_blank\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignright\" style=\"margin: 8px;\" title=\"GetJava\" src=\"http:\/\/java.com\/en\/img\/everywhere\/getjava_med.gif?cid=jdp129956\" border=\"0\" alt=\"GetJava Download Button\" width=\"100\" height=\"43\" \/><\/a>I noticed in the log file of my webserver a number of<\/p>\n<blockquote><p>java.text.ParseException: Unparseable date<\/p><\/blockquote>\n<p>messages.\u00a0 I use <a title=\"Java at Sun.com\" href=\"http:\/\/java.sun.com\" target=\"_blank\"><strong>Java<\/strong><\/a>&#8216;s SimpleDateFormat class on the server for all sorts of different date <strong>parsing<\/strong>, but ran into some extra <strong>difficulties<\/strong> on this occasion. The difficulties arose because just one of the machines here uses <strong>IE7<\/strong> on Windows XP. This browser was sending a different <strong>format<\/strong> from all the other browsers:<\/p>\n<ul>\n<li>Linux-Firefox 3: &#8220;Fri May 30 10:14:52 MYT 2008&#8221;<\/li>\n<li>Windows-Firefox 2: &#8220;Fri May 30 16:34:38 MYT 2008&#8221;<\/li>\n<li>Linux-Epiphany 2: &#8220;Fri May 30 16:34:38 MYT 2008&#8221;<\/li>\n<li>Linux-Opera 9: &#8220;Fri May 30 16:34:38 MYT 2008&#8221;<\/li>\n<\/ul>\n<ul>\n<li><span style=\"color: #ff0000;\">Windows-IE7: &#8220;Fri, 30 May 2008 08:34:38 GMT&#8221;<\/span><\/li>\n<\/ul>\n<p>I&#8217;m <strong>not convinced<\/strong> this is a <strong>locale<\/strong> problem, since it was the <strong>same<\/strong> Windows PC that produced the consistent date from Firefox 2 and the <strong>inconsistent<\/strong> date from IE7. There doesn&#8217;t seem to be a <strong>standard<\/strong> for the date format in the If-Modified-Since header field, so it seems I have <strong>no choice<\/strong> but to code my webserver for differing date formats.<\/p>\n<p>I&#8217;m <strong>currently<\/strong> using 2 different SimpleDateFormats to make the problem <strong>go away<\/strong>, but I wonder how many different formats will I get when I <strong>deploy<\/strong> this webserver? If-Modified-Since <strong>experts, your comments, please!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Everybody who has a webserver wants to use less bandwidth. A webserver sends out a lot of copies of the same information. Stylesheets, images, static HTML pages, javascript files. Many of these rarely, if ever,\u00a0 change from one visit by a browser to the next. Fortunately, there are a few schemes implemented in HTTP that [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,20,3],"tags":[33,18,105],"class_list":["post-36","post","type-post","status-publish","format-standard","hentry","category-broken","category-fixed","category-software","tag-java","tag-server","tag-software"],"_links":{"self":[{"href":"https:\/\/blog.lolyco.com\/sean\/wp-json\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.lolyco.com\/sean\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lolyco.com\/sean\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lolyco.com\/sean\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lolyco.com\/sean\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":0,"href":"https:\/\/blog.lolyco.com\/sean\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.lolyco.com\/sean\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lolyco.com\/sean\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lolyco.com\/sean\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}