Archive

Archive for March, 2009

Go rails caching!

March 31st, 2009 mahesh No comments

I had no idea caching is SO simple in rails. I added some caching to thecollegestuff.com. Two places where caching was clearly needed were the college page listing all its professors and the professor page with all the ratings. Majority of the people who land on these pages are only viewing these pages. They are not really adding content. So, it makes sense to fetch the page quickly (from the cache).

For now the way my cache expires is when someone rates a professor in which case I expire that professor page. Similarly, I expire the college page when a new professor is added. Below is a code snippet which does the caching.


class ProfessorsController < ApplicationController

caches_page :show

cache_sweeper :professor_sweeper,
:o nly => [ :create ]

caches_page is self explanatory. I have cached the show transaction.

cache_sweeper is used to expire the cache when a create method is called on the professor. Below is the sweeper code.


class ProfessorSweeper < ActionController::Caching::Sweeper

observe Professor

def after_create(professor)
expire_college_page(profesor.college_id)
end

private

def expire_college_page(collegeId)
expire_page :controller => “colleges”, :action => “show”, :id => collegeId
end

end

That is all it takes to do a page caching! I am sure I can find more places in my code which can be cached. I will have to see if I can use some action caching or fragment caching somewhere. The home page has the top professor and college list which are database queries. I have to find a nice way to cache that part of the page. I will play around next weekend. Have a good week!

Cheers,
Mahesh

Categories: Uncategorized Tags:

What are your 3 must read blogs everyday?

March 17th, 2009 mahesh 3 comments

I just noticed that there are a few blogs which I really look forward to reading everyday. Do you have any in your feed reader like that? If so, can you share it with me?

Here are the 3 I read everyday without fail

0. Seth’s

1. Fred’s

2. Jeff’s

Feel free to add yours in the comments section.

Cheers,
Mahesh

Categories: Uncategorized Tags:

End of week 1 – thecollegestuff goes nowhere

March 8th, 2009 mahesh 3 comments

It’s been a week since I put thecollegestuff.com up. There has been one registered user apart from me (ouch!). I think there are many reasons for it. I am just brainstorming here for myself. Feel free to add anything I have left out.

  • the site is just ordinary. No killer features, nothing
  • Look and feel is very average
  • There is no much content there
  • I haven’t done a good job of marketing the site
  • Let’s see what I can do to fix each of them

    Point 1: I will work on adding the features in my todo list.
    Point 2: Anyone out there who can clean up the interface a little bit? Leave a comment if you are interested!
    Point 3: This is a chicken and egg problem. Users will be motivated if there is content. But they are the ones who will have to add content. So, I don’t know what to do here.
    Point 4: I will start bugging my friends to use the site and spread the word and will look up online for some marketing techniques ;)

    That is the 3 point formula to win! I am sure I will laugh at myself looking back at this post sometime in the future. heh .. who cares. This is fun for now! The feelinig of starting a website is amazing even if it is crappy!

    That is all for now. Have a good week ahead!

    Cheers,
    Mahesh

    Categories: Uncategorized Tags: