0

I followed this tutorial to create a simple CRUD in CakePHP. Everything is working fine but for some reason when I add or delete an entry, and then click the link to go back to the list, it doesn't display an updated list with the new item or deleted item and I have to hit the refresh button to get an up-to-date list.

I've turned off caching by uncommenting this in /app/Config/core.php:

Configure::write('Cache.disable', true);

I'm not sure what else I can do to fix this.

here's a video of what I'm describing

Jonathon Klem
  • 258
  • 4
  • 19
  • Can you add the controller you use for the list and the form? Is it just plain cake-bake stuff or did you change something? – Nunser Jun 30 '14 at 19:46
  • Here's the controller. For the most part it's just cakebake stuff, but I added some code to delete to unlink() uploaded files and some code to add to accept uploaded files, but the problem existed before these additions. [here is the code](http://pastebin.com/X7n8J0M9) – Jonathon Klem Jun 30 '14 at 20:01

2 Answers2

1

Try to do redirect after your CRUD operations.

  • I edited my question to provide a video of what's happening. I'm already using flash() to redirect. For some reason it still requires a refresh. – Jonathon Klem Jun 30 '14 at 19:42
  • Are you sure that issue is not in your browser? May be you have wrong cache control headers in your requests? Try to check this in network monitoring tools of your browser. Also try to use this setting: http://book.cakephp.org/2.0/en/controllers/request-response.html#interacting-with-browser-caching – Oleg Yemelyanov Jul 01 '14 at 12:40
0

It turns out this was a simple fix, the view had aggressive caching code in it. I just had to remove that and the problem went away.

Jonathon Klem
  • 258
  • 4
  • 19
  • Could you please share the code and file to fix this issue? – Sahil Gulati Nov 01 '17 at 12:29
  • I don't have access to the code anymore, but basically it was along these lines IIRC: https://stackoverflow.com/questions/1341089/using-meta-tags-to-turn-off-caching-in-all-browsers In the view I was setting some meta content that was affecting the caching and the problem was my browser caching the output rather than pulling from the server again. – Jonathon Klem Nov 01 '17 at 17:02