1

I'm currently developing some templates in Craft. My work flow is

> Make a change to the template file
> Save the file, which automatically loads to the server
> Reload a test page in a web browser

About half the time, and somewhat erratically the adjusted template does not load. Once it is not loading, no amount of browser reloading, clearing local caches etc will help. The only thing that I have been able to find that will consistently fix this is to go in CP Settings and clear the Compiled Template cache. Obviously this is a pain to do each time, and slows my development time considerably.

Initially I tried to set a Craft config of 'cache' => false, because I read this advice somewhere, but I see it doesn't appear in the documentation, and it doesn't work. I've also tried 'cacheDuration' => 'PT1S' to no avail.

The cacheMethod is set to Default. Craft version is current.

  • A couple questions for clarification. Are you in Dev Mode, and is this on a local server or a web host of some kind? – Bryan Redeagle Apr 4 '15 at 3:32
  • This is on a remote web host, and most of the time I am not in Dev Mode, but have tried both with deMode set to true and false, but doesn't seem to change the behaviour I am seeing. – Jack McKenzie Apr 4 '15 at 3:44
1

If you're in devMode, then Twig's compiled templates will be regenerated on every request. Otherwise, they'll be regenerated when Twig sees that the source template's date modified timestamp has changed.

As of PHP 5.5+, PHP's opCache is enabled by default, which might explain what you're seeing. If you're in development, you'll want to disable that to make sure PHP isn't doing any caching at the byte level.

  • Thanks Brad. The devMode setting makes no difference to the problem. I am running PHP5.5.9, and yes opCache is enabled. I haven't had the problem running older versions of PHP, even with devMode turned off (because as you note Twig picks up the file change). I can't turn opCache off in .htaccess in this particular instance (generates a server error), although I can with an inscript PHP command, but I haven't learned how to do that in Craft yet. Thanks for your help. – Jack McKenzie Apr 4 '15 at 4:06
  • Update: I found the plug-in called PHP Tweak, and was able to disable opCache (and reflect the setting in the template in question to show that it was indeed off). But the problem remains unfortunately. – Jack McKenzie Apr 4 '15 at 4:21
1

Maybe a proxy on your side or reverse proxy on server-side. Try if adding a random number to the testpage address helps: /test-address?rand=27456

You could put a temp reload link in your testpage like this:

<a href="#" onclick="location.href=location.href+'?rnd='+Math.random()">Reload</a>
  • Thanks. I tried that but it doesn't help either. I guess the caching is happening deep in the bowls of the template system, so even when I load different entries that use the same template I still see the cached template rather than my modified one. – Jack McKenzie Apr 4 '15 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.