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 759651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:37:20+00:00 2026-05-14T15:37:20+00:00

I have a songs controller. Within the songs controller i have a ‘view’ action

  • 0

I have a songs controller. Within the songs controller i have a ‘view’ action which get’s passed an id, eg

  • /songs/view/1
  • /songs/view/5
  • /songs/view/500

When a user visits /songs/view/1, the file is cached correctly and saved as ‘songs_view_1.php’

Now for the problem, when a user hit’s a different song, eg /songs/view/2, the ‘songs_view_1.php’ is deleted and ‘/songs/view/2.php’ is in it’s place.

The cahced files will stay there for a day if I don’t visit a different url, and visiting a different action will not affect any other action’s cached file.

I’ve tried replacing my ‘cake’ folder (from 1.2 to 1.2.6), but that didn’t do anything. I get no error messages at all and nothing in the logs.

Here’s my code, I’ve tried umpteen variations all ending up with the same problem.

   var $helpers = array('Cache');
   var $cacheAction = array(
       'view/' => '+1 day'
   );

Any ideas?

EDIT:

After some more testing, this code

var $cacheAction = array(
    'view/1' => "1 day",
    'view/2' => "1 day"
);

will cache ‘view/1’ or ‘view/2’, but delete the previous page as before. If I visit ‘/view/3’ it will delete the cached page from before… sigh

EDIT:

Having the same issue on another server with same code…

  • 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-14T15:37:21+00:00Added an answer on May 14, 2026 at 3:37 pm

    After working hours on this, I finally figure out the reason why the cache keep being deleted, the REASON is because you had some operations that update your ‘song’ record in the database after you view the ‘song’. For my case, I keep a column in my database called ‘Hits’ to store the number of hits/reads, and it updates it everytime it read the record.

    Cakephp has a feature to aumotically detect changes to your database and clear the cache for you.

    Try remove any operations that update your ‘song’ record and the cacheaction should be working properly.

    An alternative is to redefine the clearcache function in your ‘song’ model… it will disable the function to auto-clear off the cache.. but then remember to manually clear the cache yourself when an update is performed.

    function _clearCache($type = null) {
    
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a controller called Music with one action which is index. On
I've made a simple app, where I have a list of songs. The user
I have a songs list-view and I want to show pop-up media player when
I have the music player application in which I have 90 songs total. I
I have a controller that has the following index action : def index if
I have a flash player that has a set of songs loaded via an
Argghh. I have a site that offers audio previews of songs hosted elsewhere. Some
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have a typical artist has_many songs model and I'm trying to set up

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.