Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Set asset mtime to the most recent source file mtime
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Nov 13, 2010
1 parent 4a61ab1 commit 8134923
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/sprockets/asset.rb
Expand Up @@ -2,12 +2,13 @@

module Sprockets
class Asset
attr_reader :environment, :source_paths, :source
attr_reader :environment, :source_paths, :source, :mtime

def initialize(environment, source_file)
@environment = environment
@source_paths = []
@source = ""
@mtime = source_file.mtime
require(source_file)
end

Expand All @@ -30,6 +31,10 @@ def process_source(source_file)
processor = Processor.new(environment, source_file)
result = ""

if source_file.mtime > mtime
@mtime = source_file.mtime
end

processor.required_files.each { |file| require(file) }
result << source_file.header
processor.included_files.each { |file| result << process(file) }
Expand Down Expand Up @@ -59,11 +64,6 @@ def etag
%("#{md5}")
end

# TODO
def created_at
Time.now
end

# TODO
def stale?
true
Expand Down
4 changes: 2 additions & 2 deletions lib/sprockets/server.rb
Expand Up @@ -85,7 +85,7 @@ def not_found_response
end

def not_modified?(asset, env)
env["HTTP_IF_MODIFIED_SINCE"] == asset.created_at.httpdate
env["HTTP_IF_MODIFIED_SINCE"] == asset.mtime.httpdate
end

def etag_match?(asset, env)
Expand All @@ -106,7 +106,7 @@ def headers(asset, env)
headers["Content-Length"] = asset.length.to_s

headers["Cache-Control"] = "public, must-revalidate"
headers["Last-Modified"] = asset.created_at.httpdate
headers["Last-Modified"] = asset.mtime.httpdate
headers["ETag"] = asset.etag

if env["QUERY_STRING"] == asset.md5
Expand Down

0 comments on commit 8134923

Please sign in to comment.