Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force refresh of images & css files in CakePHP?

Tags:

cakephp

I have a following problem.

I'm coding in CakePHP and I'm a novice. I quite often need to change some images or css files on the website. And on the website I always see the old content unless I manually press "F5" on the keyboard. And I have to do it on every workplace that uses that website.

It is irritating especially because I don't know where I can find the solution for it. I removed tmp files and cookies. Nothing helps and I don't know how can I fix it.

Could you please help me?

like image 323
Annabelle Avatar asked Jan 24 '13 01:01

Annabelle


1 Answers

For anything under \webroot, see the Asset.timestamp setting in core.php:

/**
 * Apply timestamps with the last modified time to static assets (js, css, images).
 * Will append a querystring parameter containing the time the file was modified. This is
 * useful for invalidating browser caches.
 *
 * Set to `true` to apply timestamps when debug > 0. Set to 'force' to always enable
 * timestamping regardless of debug value.
 */
    Configure::write('Asset.timestamp', true);


For this to work, you have to use the Cake helpers to create the assets (e.g. $this->Html->image(), $this->Html->css(), etc)

like image 108
Costa Avatar answered Oct 21 '22 02:10

Costa