<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -141,25 +141,28 @@ module VersionCache
         options = {:expiry =&gt; 0, :browser_cache =&gt; false}
         options = options.merge(keys.delete_at(keys.length - 1)) if keys.length != 0 &amp;&amp; keys[keys.length - 1].is_a?(Hash)
         key = &quot;#{request.host}:#{request.request_uri}:#{keys * ':'}&quot;
-        etag = Digest::MD5.hexdigest(key)        
         
-        # first handle HTTP, lets us avoid a memcache hit
-        # and saves a huge amount of bandwidth to the client
+        data = Rails.cache.read(key)
+        # let the etag depend on time so that it varies for pages that don't have versions
+        etag = data.nil? ? Digest::MD5.hexdigest(key + Time.now.to_s(:db)) : data[:headers][&quot;ETag&quot;]
+        
+        # Was the data really modified?
         if request.env[&quot;HTTP_IF_NONE_MATCH&quot;] == etag
           response.headers[&quot;X-Cache&quot;] = &quot;HTTP&quot;
+          set_cache_headers(etag, data[:browser_cache], data[:cached_on], data[:cached_for])
           head :not_modified
-          logger.info &quot;version_cache: 304 Not Modified&quot;
+          logger.info &quot;version_cache (#{key}): 304 Not Modified&quot;
           return
         end
         
         # Next check memcache
-        if data = Rails.cache.read(key)
+        if data
           # render from the cached values
           response.headers[&quot;X-Cache&quot;] = &quot;HIT&quot;
           data[:headers].each {|k,v| response.headers[k] = v}
           set_cache_headers(etag, data[:browser_cache], data[:cached_on], data[:cached_for])
           render :text=&gt;data[:body], :status=&gt;data[:headers][&quot;Status&quot;]
-		      logger.info &quot;version_cache: cache hit&quot;
+		      logger.info &quot;version_cache (#{key}): cache hit&quot;
         else
           # Finally, yield, indicate we've missed then cache the response
           response.headers[&quot;X-Cache&quot;] = &quot;MISS&quot;
@@ -172,13 +175,14 @@ module VersionCache
             set_cache_headers(etag, options[:browser_cache], cached_on, expiry)
             Rails.cache.write(key, {:body=&gt;response.body,
                                     :headers =&gt; {&quot;Status&quot; =&gt; response.headers[&quot;Status&quot;],
-                                                 &quot;Content-Type&quot; =&gt; (response.content_type || &quot;text/html&quot;)},
+                                                 &quot;Content-Type&quot; =&gt; (response.content_type || &quot;text/html&quot;),
+                                                 &quot;ETag&quot; =&gt; etag},
                                     :browser_cache =&gt; options[:browser_cache],
                                     :cached_on =&gt; cached_on,
                                     :cached_for =&gt; expiry},
                                     :expires_in =&gt; expiry)
           end
-		      logger.info &quot;version_cache: cache miss&quot;
+		      logger.info &quot;version_cache (#{key}): cache miss&quot;
 		    end
       end 
       </diff>
      <filename>lib/version_cache.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6ab00fd7c8522830af59119d1d37e6d2afe76efe</id>
    </parent>
  </parents>
  <author>
    <name>Ahmed Sobhi</name>
    <email>humanzz@hotmail.com</email>
  </author>
  <url>http://github.com/humanzz/version_cache/commit/c1d79417762de2f97624f3366ce4e22a5bfda2a7</url>
  <id>c1d79417762de2f97624f3366ce4e22a5bfda2a7</id>
  <committed-date>2009-03-12T07:41:50-07:00</committed-date>
  <authored-date>2009-03-12T07:41:50-07:00</authored-date>
  <message>the etag generated etag now depends on time</message>
  <tree>8360eca08b8f3d0c18f464d1ae7291fd7c01e65f</tree>
  <committer>
    <name>Ahmed Sobhi</name>
    <email>humanzz@hotmail.com</email>
  </committer>
</commit>
