rack-cachely 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +58 -2
- data/lib/rack-cachely/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Rack::Cachely
|
2
2
|
|
3
|
-
|
3
|
+
This is a piece of Rack Middleware for talking with the page caching service, [Cachely](http://www.cachelyapp.com). It supports any Rails/Rack application.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,63 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
**CACHELY IS CURRENTLY IN PRIVATE BETA.**
|
22
|
+
|
23
|
+
If you would like to join the private beta, please email [mark+cachely@meta42.com](mailto:mark+cachely@meta42.com)
|
24
|
+
|
25
|
+
### Rails 3.x
|
26
|
+
|
27
|
+
Step one is to set up your appropriate environment, such as `production.rb` to include the `Rack::Cachely` middleware.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
config.middleware.delete "Rack::Cache"
|
31
|
+
config.middleware.use Rack::Cachely
|
32
|
+
config.action_controller.perform_caching = true
|
33
|
+
```
|
34
|
+
|
35
|
+
Step two is to tell `Rack::Cachely` which pages you would like to cache, and for how long. `Rack::Cachely` is smart enough to know that only `GET` requests in the `200` range are valid for caching.
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
before_filter do
|
39
|
+
# Set pages to 'public' to allow them to be cached.
|
40
|
+
# set the max-age so Cachely knows how long to keep
|
41
|
+
# the pages for.
|
42
|
+
headers['Cache-Control'] = 'public; max-age=86400'
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
### Detailed Configuration
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
config.middleware.use Rack::Cachely,
|
50
|
+
# Print debug information out to the log (default is false):
|
51
|
+
verbose: false,
|
52
|
+
# Each Cachely account has a custom URL endpoint.
|
53
|
+
# The URL can be found in your Heroku config or through
|
54
|
+
# your Cachely dashboard. By default it looks for an
|
55
|
+
# ENV variable named CACHELY_URL:
|
56
|
+
cachely_url: ENV["CACHELY_URL"],
|
57
|
+
# How long are you willing to wait for requests to the Cachely
|
58
|
+
# service to respond? Default is 1 second.
|
59
|
+
timeout: 1.0
|
60
|
+
```
|
61
|
+
|
62
|
+
### Helpful Query Parameters
|
63
|
+
|
64
|
+
`Rack::Cachely` has a few helpful query string parameters you can add to do different things:
|
65
|
+
|
66
|
+
**no-cachely=true**: This will bypass Cachely and show you the page directly from your application. Great for debugging and testing pages.
|
67
|
+
|
68
|
+
**refresh-cachely=true**: This will delete the page from Cachely and re-cache it. Great when you've made changes and want to update the cache, but don't feel like doing it on the command line or through the dashboard.
|
69
|
+
|
70
|
+
### Expiring Pages Programmatically
|
71
|
+
|
72
|
+
When your system gets updated it would be nice to be able to programmatically expire pages that are associated with certain objects. Cachely let's you expire pages in your cache using Regular Expressions, to help make your life that much easier.
|
73
|
+
|
74
|
+
```Ruby
|
75
|
+
# Destroy all "user" pages, eg. "/users/1", "/users/2", etc...
|
76
|
+
Rack::Cachely::Store.delete("users/\d+")
|
77
|
+
```
|
22
78
|
|
23
79
|
## Contributing
|
24
80
|
|
data/lib/rack-cachely/version.rb
CHANGED