Roots Discourse

Deleting the cache for blade templates

Hi,

My blade template isn’t updating. I reverted some breaking changes to the template and it’s not correctly reloading on the site.

I deleted the upload/cache directory. Is there anything else I need to do?

2 Likes

Deleting the upload/cache directory wipes out all your cached blades, which will cause them to be re-rendered. This can take a couple minutes (they seem to get kind of…cached somewhere else?) but it will work.

If you deleted the cache folder a while ago, and you’re still seeing issues, I’d guess one of the following is happening:

  • The error you were trying to correct in your templates is still there.
  • If this site is on a live server, the files may still be cached elsewhere (by the server, depending on your configuration, or something else like Cloudflare).
  • If the site is on a live server and you’re using Trellis, Trellis deploys do not (by default) regenerate or wipe out blade caches, so deleting your local cache will have no effect on your remote site.
  • You’ve somehow accidentally reconfigured your theme to store templates in another location, and haven’t wiped that location (this seems very unlikely).

If you could post some of the code in question, it might help with debugging.

2 Likes

@alwaysblank Do you know where this “somewhere else…” location is?

I’ve been trying to figure out how to get a normal dev workflow going but this cache is making it nearly impossible, clearing it out every so often is sort of working but I still see the same old files for about 10 minutes after I delete the cache.

2 Likes

I too find this infuriating. I’m surprised that no-cache is not configured out of the box. Maybe it’s my mistake

Without more details it’s difficult to determine what might be causing the problem you’re encountering, but when I’ve run into issues where blades don’t seem to update even after being deleted, it’s usually a filesystem issue–i.e. if you’re using a VM for local development, sometimes the sync mechanism certain VMs use to synchronize files between the host and guest will not be triggered, or runs on a long timer and your blades “stick” for a while.

1 Like

Yes, I believe this is the case.

Perhaps too early to tell whether it fixed the issue, but after reconfiguring this file:

# trellis/roles/php/defaults/main.yml
...
php_opcache_fast_shutdown: 0 # was 1
php_opcache_revalidate_freq: 0 # was 1
...

then rebooting the vm via vagrant halt && vagrant up

This seems to relieve the issue. However, I’m concerned whether I should configure a more dev-specific file, such as trellis/group_vars/development/php.yml, which also contains only the php_opcache_enable: 0 and not the php_opcache_revalidate_freq: 0.

@alwaysblank are VM’s server caches known to “stick” a while, or perhaps get squirrley after running for extended periods? Apologies if this is out of scope to roots. Perhaps merely rebooting the VM fixed the issue.

I can’t comment w/ any sort of authority w/r/t the behavior of VMs in general. My own experience has been that sometimes when I was using VirtualBox I would end up in a situation where whatever mechanism it uses to sync shared files would seem to choke on blades. I don’t know exactly why, but I suspect that it had to do with the filesystem reporting (or not reporting) that something had changed to the VM–I was using Windows at the time. Unfortunately I wouldn’t know how to replicate the issue nor do I remember how I fixed it (if I even did), but iirc it was intermittent. These days I use devilbox for my local dev environment and it’s generally faster and more reliable (although it doesn’t benefit from the automatic project setup that Trellis can do w/ VMs).

@alwaysblank Thanks for helping me understand the VM landscape better! :smiley:

I did steal the solution from another discourse post. Happy to add to the chorus on this solution.