[1.5.4] HTMLHead() issue

Hi there,

In my “blog” layout I have a Widget which places some JS and CSS files using HTMLhead() function and all works fine.

If I use the same widget in “pages” layout instead of “blog” works when I first visit the page, but when I reload or re-enter the same page the code that the HTMLHead() places is gone, all other html body elements rendered from the widget are visible but all css and js files no longer shows between the head.

If I reload the Application it works, but again if I reload or re-visit the page… the head placed code is gone.

Any ideas?

I think I got this…

In Cache Settings if I Set “Caches all generated page+layout HTML” to NO
the HTMLHead() keeps in place.

Any opinion?

Felipe Serrano

Yes because the content is cached and htmlhead does not output like normal bit when cf wants so ContentBox can’t get to it.


  • don’t send it to HTML head but generated out
  • don’t cache the pages

I’m guessing you have event caching turned on. The output of the page is probably being cached, but ColdBox event caching doesn’t work for stuff like HTMLHead since that’s written directly to an internal buffer and now part of the main output stream that CF caches.

Can you switch up your code to output the JavaScript inline instead? The only other option is probably to turn off caching.



ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

There are two ways you can solve this.

  1. As Brad and Luis suggested, don’t cache the page.

  2. Write a module that contains the widgets and introduce an interceptor.

I have been meaning to blog about this for some time, the idea is that the interceptor and widget work together. The interceptor hooks into is called when the html head interception is announced. But you do have to package the widget and interceptor together in this case.

For single widgets for distribution this becomes a problem, and you either have to not put the JS into the header or not cache the page. If you are developing for a one of solution then the interceptor and widget as a complete module would be a far better alternative solution as it makes the page neater as you would appreciate.

Thank you all :slight_smile: For now I’ll mange it by not “caching” it