| «« Page Caching and Personalized Content | Closing Discussion Threads »» |
|
About
I'm Ryan Lowe, a Software Engineering graduate living in Ottawa, Canada. I like agile software development and Ruby on Rails.
I write this blog in Canadian English and don't use a spell checker. Typos happen.
Projects
» Full-time Ruby on Rails freelancer
» Full-time with Rails since May 2005 » Former committer for RadRails (now Aptana) » I also have a few Rails side-projects in development: 1. wheretogoinTO.com Toronto nightlife 2. Hey Heads Up! TODO list and sharing 3. Layered Genealogy family history research 4. foos for foosball scoring 5. fanconcert for music fans (on hold) Hiring Rails developers? I can telecommute by the hour from Ottawa, Canada »» Email: rails AT ryanlowe DOT ca
BulletBlog
Now hosted on Hey! Heads Up -- check it out!
Syndication
Pings
Recent
Derek Lowe's (Ryan's older brother) words at Ryan's funeral
blog@ryanlowe.ca no more Forging Email Headers: Good, Bad or Ugly? Sarcastic Dictionary (Part 1 of Many) Tags Hierarchies Twisting Rails is Risky Business Risky Business? My Take on Early Alphas Whoa, it's August 2007 Closing Comments A Postscript to "Growth at the grassroots" »» All Blog Posts
Linkage
del.icio.us/ryanlowe
technorati/ryanlowe.ca/blog Aurora Roy Jim Andrew Trasker Travis Kibbee Karen Dr. Unk Ayana Van Bloggers Joel Spolsky Robert Scoble Tim Bray Dave Winer Raymond Chen James Robertson Ruby/Rails Bloggers rubyonrails.org weblog David Heinemeier Hansson Dave Thomas James Duncan Davidson Mike Clark Jamis Buck Signal vs. Noise Tobias Luetke Amy Hoy: (24)slash7 Jeremy Voorhis Eclipse Bloggers Planet Eclipse EclipseZone Luis de la Rosa Eclipse Foundation Kim Horne Billy Biggs Ian Skerrett Mike Milinkovich Bjorn Freeman-Benson Denis Roy
Archives
|
Page Caching and Time Zones
Speaking of page caching on FanConcert another interesting problem with caching exists: dates! Right now, FanConcert operates in GMT. That was fine because no one really noticed times that much. Now that discussion forums and blogs are in FanConcert, times are more obvious. It's becoming much more important to represent time properly, especially to the user's local time zone. A user should be able to set a timezone in their preferences and all of the times they see on FanConcert should be shown in this time. This can be a problem if the forum pages are cached! Or is it? Maybe not... What if all of FanConcert's cached pages had times stored in GMT and I took advantage of Javascript support on browsers to convert the GMT time to whatever time zone the user is in. Then I could insert the converted time into the page and all of the times would seem local to the user. I'd like to do this on FanConcert ASAP. I wonder how much support Javascript has for time zones already? How well is it supported by the major browsers? Posted at February 25, 2006 at 01:04 AM ESTLast updated February 25, 2006 at 01:04 AM EST Comments
Depending on how you accomplish your caching, it may be possible to output times with a special tag around them, then, before they are sent out, search for the tags, and replace all the times as applicable. » Posted by: Kibbee at February 25, 2006 02:51 PMOn the server side you mean? I was thinking of doing the same thing, just on the client side -- letting the browser replace the times with the converted local time. As far as I understand it, Ruby on Rails will store the cached page as a file. I'm not 100% sure the cached page can't be modified before it is sent but if I had to guess I'd say that it can't be modified. » Posted by: Ryan at February 25, 2006 02:56 PMIt might be too good to be true but I didn't seem to have any problems with this. Browsers come with a function called Date.UTC() which takes a UTC time which you can just put into the browser's date constructor: localDate = new Date(Date.UTC(y,m,d,hr,mn)); When you output that date it's in the browser's local time. I just output the UTC time from the server into the middle of some Javascript code that does document.write() to put the local date there. You can dig into FanConcert's Javascript if you're really interested. » Posted by: Ryan at February 25, 2006 10:33 PMyeah, I just have pissues using javascript implementations where I could do something server side. It's comes from the old days of doing Javascript for Netscape 4 vs. IE 4. There are still some times when Javascript is nice, but I always like to keep it to a minimum. It's a nice little JS hack you did, and probably the simplest way to fix the problem. But what about the half of the population who either have their time set incorrectly or just clicked continue when windows asked about their time zone, and therefore picked PST, event though they live in EST, or England. » Posted by: Kibbee at February 26, 2006 09:53 PM |