2013-01-24 10 views
8

Ho un problema seguente.Come forzare l'aggiornamento di immagini e file css in CakePHP?

Sto codificando in CakePHP e sono un novizio. Ho abbastanza spesso bisogno di cambiare alcune immagini o file CSS sul sito web. E sul sito web vedo sempre il vecchio contenuto a meno che non prema manualmente "F5" sulla tastiera. E devo farlo su ogni posto di lavoro che utilizza quel sito web.

È irritante soprattutto perché non so dove trovo la soluzione. Ho rimosso i file e i cookie tmp. Niente aiuta e non so come posso aggiustarlo.

Potrebbe aiutarmi per favore?

risposta

15

Per nulla sotto \ webroot, vedere l'impostazione Asset.timestamp 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); 


Per far funzionare tutto questo, è necessario utilizzare gli helper Cake per creare le attività (ad esempio $this->Html->image(), $this->Html->css(), ecc.)

+0

Grazie mille! 'Asset.timestamp' era esattamente ciò di cui avevo bisogno. – Annabelle

+0

Come aggiungere la versione ai file di asset CakePHP (JS e CSS)? – Deepak

+0

Does Cake sa automaticamente aggiornare un file con un vecchio timestamp o hai ancora bisogno di passarlo attraverso un filtro Configure css.php? Per esempio vedo un comando in UrlHelper.php presumibilmente lo fa automaticamente. – efwjames

Problemi correlati