Skip to content

Stash checksum and/or timestamp in Redis #37

Open

Description

@mwpastore

Similar to #25, it would be fantastic if ember-deploy-redis would also stash a checksum (or the commit SHA) and/or a build date/time (or the commit timestamp) of the index to use in the the ETag and Last-Modified HTTP headers. Something like:

foo:index:current => '<!DOCTYPE html>...'
foo:index:current:meta => checksum '787b3dd284fd99202adfa4e18a28126d159552c5' 
                          timestamp 'Wed Sep 16 19:28:37 2015 +0200'

And then...

require 'sinatra'
require 'redis'

get '/' do
  content_type 'text/html'
  expires 3_600, :public

  redis = Redis.new
  index_key = redis.get("foo:current")
  index_key = "foo:#{params[:index_key]}" if params[:index_key]

  meta = redis.hgetall("#{index_key}:meta")
  etag meta[:checksum]
  last_modified meta[:timestamp]

  redis.get(index_key)
end

Stashing the content in the same hash as the metadata would be ideal (to limit the Redis hits) but would break backwards compatibility.

Activity

  1. achambers commented on Oct 1, 2015

    @achambers
    Member

    Thanks for the suggestion @mwpastore. As you can see from the issue you referenced, this is something we've been thinking about. This will also require a change to the ember-cli-deploy/ember-cli-deploy-revision-data repo which is designed to retrieve all that sort of meta data info. Then it will be up to the redis plugin to upload it.

    Thanks for the suggestion, we'll look in to it.

    As always, PR's are always welcome 👍

  2. mwpastore commented on Oct 1, 2015

    @mwpastore
    Author

    I suspect that it would be way above my skill level, after reviewing both components last night, but I will certainly give it a try. Thanks @achambers!

  3. mwpastore commented on Oct 1, 2015

    @mwpastore
    Author

    Duh, we can just use the revisionKey as the ETag, and the timestamp is already being delivered by
    ember-cli-deploy-revision-data, so this should be easier than I thought...

  4. achambers commented on Oct 1, 2015

    @achambers
    Member

    Perfect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions