1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

opcache isn't invalidated when saving template

Discussion in 'XenForo Suggestions' started by Jake B., Apr 28, 2016.

  1. Jake B.

    Jake B. Well-Known Member

    When you save a template and are using the 'render templates from files' option it can take quite a bit of time before the changes actually render due to the OpCache. You can use opcache_invalidate to invalidate specific files so the change will be more immediate
    Xon likes this.
  2. pegasus

    pegasus Well-Known Member

    opcache_invalidate only exists for PHP > 5.5.0. XenForo works for older PHP versions too. Have you tried turning on the opcache.revalidate_timestamps directive? This should work for all PHP versions.
  3. Chris D

    Chris D XenForo Developer Staff Member

    Going to go ahead and call this a suggestion for now.

    We could, of course, only conditionally run it if the method exists but bear in mind there are other workarounds and also older and different opcache systems that have been affected by similar issues which wouldn't be affected by this change.

    For development I switch it off in config.php (or php.ini of course):
    For a live site, have opcache.validate_timestamps switched on, but have opcache.revalidate_freq at a reasonable figure. The default is 2 seconds. I've seen some setups have this as high as 120! That's pretty extreme, but 1-2 seconds seems reasonable to me. By the time the changes have been made, the template re-compiled and you going to check the changes, it should have revalidated by then on its own.

Share This Page