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

  • Home
  • SEARCH
  • 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 912241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:20:50+00:00 2026-05-15T17:20:50+00:00

How can I clear a page cache. I tried impelemnting cache but switched it

  • 0

How can I clear a page cache. I tried impelemnting cache but switched it off, now my home page always loads the cached version. I tried the following rake task no luck.

namespace :cache_clear do
    desc 'clear a page cache'
    task :expire_cache => :environment do
        ActionController::Base::expire_page('/')
        puts "Cache cleared"
    end
end

Here is my home page code, it shows partials that essentially present collection of other models. Does this have something to do with it?

<div class="span-17 last">
<%= render :partial => "top_votes" %>
</div>

<% content_for :right_nav do %>
  <%= render :partial => "latest_votes" %>
  <%= render :partial => "whos_voting" %>
  <%= render :partial => "top_voters" %>

<% end %>

I even tried to expire the cache from a sweeper,

in my vote_topic controller I have

cache_sweeper :home_sweeper

class HomeSweeper < ActionController::Caching::Sweeper
    observe VoteTopic
  def after_index(vote_topic)
    expire_cache(vote_topic)
  end

  def expire_cache(vote_topic)
     expire_page :controller => :home, :action => :index
  end
end

That doesn’t work either, I do have cache turned off in my development.rb file.

  • 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-15T17:20:51+00:00Added an answer on May 15, 2026 at 5:20 pm

    The page cache is always on disk, so you will need to actually clear out the files/directory you want to flush. It’s an unfortunate way to cache.

     cache_dir = ActionController::Base.page_cache_directory
     unless cache_dir == RAILS_ROOT+"/public"
       FileUtils.rm_r(Dir.glob(cache_dir+"/*")) rescue Errno::ENOENT
     end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can read the MySQL documentation and it's pretty clear. But, how does one
I find it annoying that I can't clear a list. In this example: a
Can anyone provide a clear explanation / example of what these functions do, and
Can anybody give a clear explanation of how variable assignment really works in Makefiles.
How can I set, clear, and toggle a bit?
Can Thread.getContextClassLoader() be null ? The javadoc is not really clear. Should a library
I've googled around and can't find a clear answer. I simply want to start
Or, to be more clear, how can I format a block of text (in
Does anyone have any suggestions as to how I can clean the body of
How can i clean and modify data from a form in django. I would

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.