Permalink
Browse files

added caching for everyone, etc

  • Loading branch information...
1 parent 31fa536 commit 8c5c1fee47f85c149b3ddb28147a4b147b43fceb @cyx cyx committed Mar 21, 2010
View
@@ -13,20 +13,27 @@ def current_account
everyone.index do
@items = current_account.items.latest.paginate(page: params[:page])
@page_title = "Everyone's Items"
+
+ cache_control :public, :must_revalidate, :max_age => 60
+
haml :'items/index'
end
everyone.get 'most-viewed' do
@items = current_account.items.most_viewed.paginate(page: params[:page])
@page_title = "Most Popular Items"
+ cache_control :public, :must_revalidate, :max_age => 60
+
haml :'items/index'
end
everyone.get 'liked' do
@items = current_account.likes_items.paginate(page: params[:page])
@page_title = "Most Liked Items"
+ cache_control :public, :must_revalidate, :max_age => 60
+
haml :'items/index'
end
@@ -19,4 +19,8 @@ class Main
self.current_user = nil
redirect root_url
end
+
+ post '/session/state' do
+ haml :'session/state', :layout => false
+ end
end
@@ -15,6 +15,7 @@
= partial :'shared/usernav'
= yield
+ = partial :'shared/footer'
= javascript_include_merged :base
@@ -28,4 +29,4 @@
var pageTracker = _gat._getTracker("UA-15297465-1");
pageTracker._trackPageview();
} catch(err) {}
- = partial :'shared/footer'
+
@@ -0,0 +1,15 @@
+- logged_in do
+ %ul.notList.colR.meta-nav
+ - not_viewing_own_account do
+ %li.colL.back-link
+ = link_to 'Back to your shelf', user_url(current_user)
+ - viewing_other_account do
+ %li.colL.back-link
+ = link_to t('back_to_persons_shelf', person: @account), user_url(@account)
+ %li.colL.logout-nav
+ = link_to 'Logout', logout_url
+
+- logged_out do
+ %ul.notList.colR.meta-nav
+ %li.colL.login-nav
+ = link_to 'Login with Twitter', login_url
@@ -24,26 +24,12 @@
= partial :'shared/meta/all'
.subnav.clearFix
- .col16-2.centerize
+ #session-state.col16-2.centerize
- show_toggling do
%ul.notList.clearFix.colL.subnav-switch
%li.colL{ :class => ('active' if user_url(@account) == request.fullpath) }
= link_to 'Bought', user_url(@account)
%li.colR{active_if('/liked')}
= link_to 'Liked', liked_path(@account)
- - logged_in do
- %ul.notList.colR.meta-nav
- - not_viewing_own_account do
- %li.colL.back-link
- = link_to 'Back to your shelf', user_url(current_user)
- - viewing_other_account do
- %li.colL.back-link
- = link_to t('back_to_persons_shelf', person: @account), user_url(@account)
- %li.colL.logout-nav
- = link_to 'Logout', logout_url
-
- - logged_out do
- %ul.notList.colR.meta-nav
- %li.colL.login-nav
- = link_to 'Login with Twitter', login_url
+
View
@@ -4,6 +4,11 @@ defaults: &defaults
:session:
:key: "rack.session"
+ :cache:
+ :verbose: true
+ :metastore: "file:tmp/cache/rack"
+ :entitystore: "file:tmp/cache/rack"
+
:photos:
:storage: :file
:root: ':root/public'
@@ -40,3 +45,7 @@ defaults: &defaults
:s3_access_key_id: "1K4Y2FT2FFD0WYZJYT02"
:s3_secret_access_key: "qWCV1IOH/BkkqyrSMuL86/gzbnsC55QxAhy18uD/"
+ :cache:
+ :metastore: "memcached://localhost:11211"
+ :entitystore: "memcached://localhost:11211"
+
View
@@ -15,6 +15,8 @@
require 'lilypad'
require 'bebop'
require 'resque'
+require 'rack/contrib'
+require 'rack/cache'
begin
require 'mysql'
@@ -42,6 +44,8 @@ class Main < Monk::Glue
class << logger; alias :write :info; end
use Rack::CommonLogger, logger
+ use Rack::ETag
+ use Rack::Cache, settings(:cache)
helpers Twitter::Login::Helpers
helpers WillPaginate::ViewHelpers::Base
@@ -3,6 +3,15 @@
$.ajaxSettings.accepts._default = "text/javascript, text/html, application/xml, text/xml, */*";
$('form.remote-form').remoteForm();
+
+ $.ajax({
+ 'url': '/session/state',
+ 'dataType': 'html',
+ 'type': 'post',
+ 'success': function(data) {
+ $('#session-state').append(data);
+ }
+ });
$('.delete-item a').click(function() {
if (window.confirm('Are you sure you want to delete this item?')) {

0 comments on commit 8c5c1fe

Please sign in to comment.