Time based etags

In my app I am serving certain controller actions every x many
minutes. For example, most popular posts are generated in memcached
every 30 minutes and served from there.

I would like to use etags/last_modified so that I am not even
rendering the same “most_popular” view for the same client within
that 30 minute period. However I am not sure how to generate an etag
or a last_modified would suit this situation.

the flow would be something like.

#Posts controller

def index
case ‘listing_type’
when ‘all_posts’
if stale?(:last_modified => “timestamp that doesn’t
change for 30 minutes”)
@posts = get_posts_from_memcached
end
end

Short of saving this timestamp to the db…how else can I create a
last_modified that time that works for this?