CakePHP caching issue when redirecting back to the same page

I am using CakePHP 2.6

I have a problem where I am redirected back to the same view where the request was made from. The view appears to be cached, so any changes made during the request are not shown until the page is refreshed again.

It means:

  • the user cannot see the changes that have just been made.
  • Flash messages are displayed in the following view (which is bad).

Why is this happening?

Things I've checked:

  • Caching is disabled in my PHP environment
  • My CakePHP's configurations are the default (see below).
  • Caching should be disabled because I'm in debug mode: Configure::write('debug', 2);

  • I am testing in multiple browsers with and without caching enabled.

Configure::write('Session', array( 'defaults' => 'php' ));

Typical example:

    //Inside ListingsController...

    $this->Listing->id = $id;
    if ($this->Listing->save($listing)) {
        $this->Flash->success(__('"%s" is now active.', $listing['Listing']['title']));
    } else {
        $this->Flash->error(__('Problem activating'));
    }
    //this is the original view...
    $this->redirect( array('controller'=>'listings', 'action'=>'mylistings') ); 

      

+3


source to share


2 answers


I have the same problem. Did you find the reason for all this? Since I was trying to solve the problem I saw this in my answer headers

Age 0 
Connection keep-alive 
Date Tue, 21 Apr 2015 08:47:21 GMT 
Server ATS/3.2.4

      



All the files with 304 Not Modified Status

had an Apache Traffic Server (ATS) (from my local network), which made me think that this is the one causing all this; I forced not to cache as described here and I have no more problems.

+1


source


Try to redirect this to referent

$this->Listing->id = $id;
if ($this->Listing->save($listing)) {
    $this->Flash->success(__('"%s" is now active.', $listing['Listing']['title']));
    // Redirect the referer
    $this->redirect(
        $this->referer()
    );
} else {
    $this->Flash->error(__('Problem activating'));
}

      



Thank!..

0


source







All Articles