Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 709427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:30:11+00:00 2026-05-14T04:30:11+00:00

Here’s the setup. I have web site which is essentially a simple CMS. Here

  • 0

Here’s the setup. I have web site which is essentially a simple CMS. Here is the routes file:

map.connect ':url', :controller => :pages, :action => :show
map.root :controller => :pages, :action => :show, :url => "/"

The page controller is thus:

class PagesController < ApplicationController
  before_filter :verify_access, :except => [:show]

  # Cache show action if we are not logged in.
  caches_action :show, :layout => false, :unless => Proc.new { |controller| controller.logged_in? }

  def update
    @page = Page.find(params[:id])

    respond_to do |format|
      expire_action :action => :show, :url => @page.url

So when a visitor hits “/” it maps to :controller => “pages, :action => “show, :url => “/”. This generates a cached version on first try, then returns the appropriate result there after. The log files show:

Processing PagesController#show (for 127.0.0.1 at 2009-08-02 14:15:01) [GET]
  Parameters: {"action"=>"show", "url"=>"/", "controller"=>"pages"}
Cached fragment hit: views/out.local// (0.1ms)
Rendering template within layouts/application
Filter chain halted as [#<ActionController::Filters::AroundFilter:0x23eb03c @identifier=nil, @method=#<Proc:0x01904858@/Library/Ruby/Gems/1.8/gems/actionpack-2.3.3/lib/action_controller/caching/actions.rb:64>, @kind=:filter, @options={:only=>#<Set: {"show"}>, :if=>nil, :unless=>#<Proc:0x025137ac@/Users/askegg/Sites/out/app/controllers/pages_controller.rb:6>}>] did_not_yield.
Completed in 2ms (View: 1, DB: 0) | 200 OK [http://out.local/]

OK – all good so far. When I update the page, it should expire the cache (see above). The logs show:

  Page Load (0.2ms)   SELECT * FROM "pages" WHERE ("pages"."id" = 3) 
  Page Load (0.1ms)   SELECT "pages".id FROM "pages" WHERE ("pages"."url" = '/' AND "pages".domain_id = 1 AND "pages".id <> 3) LIMIT 1
Expired fragment: views/out.local/index (0.1ms)
Redirected to http://out.local/pages/3
Completed in 9ms (DB: 0) | 302 Found [http://out.local/pages/3]

See the problem? Rails is clearing the cache named “index”, but it sets it as “/”. Naturally this results in the cache NOT being cleared, so visitors are now seeing the old version.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:30:11+00:00Added an answer on May 14, 2026 at 4:30 am

    I haven’t used action caching, but I know that using page caching if I cache a page such as “/posts/index” and I also make that my root_url, Rails will cache it as both:

    RAILS_ROOT/public/index.html
    RAILS_ROOT/public/posts/index.html
    

    To expire them both, in my sweeper I have to do:

    expire_page :controller => 'posts', :action => 'index'
    expire_page '/index'
    

    So perhaps expire_action will also just take a string path arg?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 366k
  • Answers 366k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I don't know what the shortcut is for switching between… May 14, 2026 at 4:35 pm
  • Editorial Team
    Editorial Team added an answer As a list of strings? timeList = [ '0:00:00', '0:00:15',… May 14, 2026 at 4:35 pm
  • Editorial Team
    Editorial Team added an answer By adding the ashx handlers to the 12\TEMPLATE folder you… May 14, 2026 at 4:35 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.