Skip to content

Instantly share code, notes, and snippets.

@DrummerHead
Last active October 10, 2015 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrummerHead/3639873 to your computer and use it in GitHub Desktop.
Save DrummerHead/3639873 to your computer and use it in GitHub Desktop.
Lean UX Crowd-Sourced User-Validated Synergized Ruby Server for Lean Localhost testing
require 'webrick'
include WEBrick
class NonCachingFileHandler < HTTPServlet::FileHandler
def prevent_caching(res)
res['ETag'] = nil
res['Last-Modified'] = Time.now + 100**4
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
res['Pragma'] = 'no-cache'
res['Expires'] = Time.now - 100**4
end
def do_GET(req, res)
super
prevent_caching(res)
end
end
local_magia = HTTPServer.new(
:Port => 8080,
:DocumentRoot => "."
)
local_magia.mount("/", NonCachingFileHandler, './')
trap("INT") do
local_magia.shutdown
end
local_magia.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment