Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

have cache TTL settings in config.yml

  • Loading branch information...
commit 0447518724aac02779e5e554987529cc20ce6d24 1 parent d56d5d8
@mislav authored
Showing with 17 additions and 8 deletions.
  1. +8 −8 app.rb
  2. +9 −0 config.yml
View
16 app.rb
@@ -39,7 +39,7 @@
end
config.cache = Instagram::FailsafeStore.new settings.cache_dir,
- namespace: 'instagram', expires_in: 20.minutes,
+ namespace: 'instagram', expires_in: settings.expires.api_cache,
exceptions: %w[Faraday::Error::ClientError Timeout::Error]
end
@@ -227,7 +227,7 @@ def photos_by_tag(tag)
@photos = popular_photos
@title = "Instagram popular photos"
- expires 15.minutes, :public
+ expires settings.expires.popular_page, :public
haml :index
end
@@ -236,7 +236,7 @@ def photos_by_tag(tag)
@title = "Instagram popular photos"
content_type 'application/atom+xml', charset: 'utf-8'
- expires 1.hour, :public
+ expires settings.expires.popular_feed, :public
builder :feed, layout: false
end
@@ -262,7 +262,7 @@ def photos_by_tag(tag)
@title = "Photos by #{@user.username} on Instagram"
content_type 'application/atom+xml', charset: 'utf-8'
- expires 1.hour, :public
+ expires settings.expires.user_feed, :public
last_modified_from_photos(@photos)
builder :feed, layout: false
end
@@ -273,7 +273,7 @@ def photos_by_tag(tag)
raw_json = user_photos(user, :raw_json)
content_type "application/#{callback ? 'javascript' : 'json'}", charset: 'utf-8'
- expires 1.hour, :public
+ expires settings.expires.user_json, :public
etag Digest::MD5.hexdigest(raw_json)
if callback
@@ -292,7 +292,7 @@ def photos_by_tag(tag)
@per_page = 20
@title = "Photos by #{@user.username} on Instagram"
- expires 30.minutes, :public
+ expires settings.expires.user_page, :public
last_modified_from_photos(@photos)
haml(request.xhr? ? :photos : :index)
end
@@ -303,7 +303,7 @@ def photos_by_tag(tag)
@tags = tag_search(@query)
@photos = []
- expires 10.minutes, :public
+ expires settings.expires.search_page, :public
haml :index
end
@@ -313,7 +313,7 @@ def photos_by_tag(tag)
@photos = photos_by_tag(@tag)
@per_page = 20
- expires 10.minutes, :public
+ expires settings.expires.tag_page, :public
haml(request.xhr? ? :photos : :index)
end
View
9 config.yml
@@ -7,6 +7,15 @@ default: &defaults
api_url: <%= ENV['INDEXTANK_API_URL'] %>
mongodb:
url: <%= ENV['MONGODB_URL'] %>
+ expires:
+ api_cache: <%= 20 * 60 %>
+ popular_page: <%= 15 * 60 %>
+ popular_feed: <%= 60 * 60 %>
+ user_feed: <%= 60 * 60 %>
+ user_json: <%= 60 * 60 %>
+ user_page: <%= 30 * 60 %>
+ search_page: <%= 10 * 60 %>
+ tag_page: <%= 10 * 60 %>
development:
<<: *defaults
Please sign in to comment.
Something went wrong with that request. Please try again.