samsm / rack-static-if-present

Like Rack::Static. Except only if there is a static file to serve.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refreshing the web page causes the static file read to be missed

jrobertson opened this issue · comments

Hello,

When I run the following code and add a text file called test.txt into the directory fun, it gets read on every subsequent web page refresh. Here's the code I used:

require 'rack-static-if-present'

use Rack::StaticIfPresent, :urls => ["/",'hidden.txt'], :root => "fun"

hello_world = lambda do |env|
  [200, {"Content-Type" => "text/plain"}, ["Hello World!"]]
end

run hello_world

If I open the URL from the address bar more than once there isn't a problem. Which suggest there is some sort of caching request being sent from the browser that needs to be handled.

--
James Robertson

Hmm! I barely remember the rationale for this gem!

It's not immediately obvious to me how that would happen, although this isn't a lot of code so maybe I'll look at it later. Do you have any more specific ideas?