Last active
August 29, 2015 14:15
-
-
Save Krishna/36d056f94260ae161a4c to your computer and use it in GitHub Desktop.
Sinatra caching problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ Sinatra Lab curl -v http://localhost:4567/cache | |
* Hostname was NOT found in DNS cache | |
* Trying ::1... | |
* connect to ::1 port 4567 failed: Connection refused | |
* Trying 127.0.0.1... | |
* Connected to localhost (127.0.0.1) port 4567 (#0) | |
> GET /cache HTTP/1.1 | |
> User-Agent: curl/7.37.1 | |
> Host: localhost:4567 | |
> Accept: */* | |
> | |
< HTTP/1.1 200 OK | |
< Content-Type: text/plain;charset=utf-8 | |
< Cache-Control: public, must-revalidate, max-age=3600 | |
< Expires: Fri, 20 Feb 2015 17:27:42 GMT | |
< Content-Length: 48 | |
< X-Content-Type-Options: nosniff | |
< Connection: keep-alive | |
* Server thin is not blacklisted | |
< Server: thin | |
< | |
* Connection #0 to host localhost left intact | |
This page rendered at 2015-02-20 16:27:42 +0000.% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
before do | |
content_type :txt | |
end | |
get '/' do | |
"Hello world!" | |
end | |
get '/index' do | |
erb :index | |
end | |
get '/moshi' do | |
# example of using a erb template | |
@name = 'Joe Random' | |
erb :moshi | |
end | |
get '/cache' do | |
expires 3600, :public, :must_revalidate | |
"This page rendered at #{Time.now}." | |
end | |
__END__ | |
@@index | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Inline template</title> | |
</head> | |
<body> | |
<h1>Are you having INLINE TEMPLATED fun yet?</h1> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment