Ok, I have a problem that is driving me crazy. I have probably spent about 10 of the last 24 hours trying to fix it.

Changes to my theme's html.tpl.php file are not recognised, and drupal seems to be using some old version of html.tpl.php which presumably it has cached somewhere in the database, which I have no idea where it is storing it or why it is using it.

I am not sure which database tables would be safe to delete to try to fix this?

Clearing the drupal cache does not update changes I have made to this file. Clearing the theme registry does not update changes.

I will go into quite a lot of detail here so here goes...

Here is the initial issue:
- My 'Addthis' buttons were suddenly taking about 90 seconds to load on each page. So, I checked the javascript debugger. The actual addthis script is working fine, but some old advertising script I have in there from 'advertisingspace.com' is timing out and not loading, and the addthis script doesn't load until after this timeout. Ok, no worries, I've found the problem, just remove the advertisingspace.com code and the problem should go away. So i removed it from the "head" section of html.tpl.php.

The error did not go away. So i checked the page source. The code is still there in the source, even though its no longer in html.tpl.php

Weird. So I ran cron a few times, cleared the cache about 20 times. Still nothing. So I went to bed and left it overnight. Still nothing.

So, i deleted html.tpl.php. The problem goes away. For some reason, this doesn't break my theme either. It makes a few minor alterations (the worse of these being it removes my iOS app banner which shows up for iOS devices, as this code is also contained in this file.)

I re-uploaded html.tpl.php. Problem recurs. The offending code is present again if you view the page source, even though, it is not in this copy of html.tpl.php. What the hell is going on here?!

Ive checked everywhere for other copies of html.tpl.php. Nope. The only other copy is in the 'system' module and this has no offending code either.

Deleting the file makes the problem go away, but i still need html.tpl.pgp for other stuff, so this is not really a solution. So, for whatever reason, if there is no html.tpl.php, drupal ignores it, but when it is present, it sees that it is present, but then loads some data from somewhere with a cached version of content, rather than actually looking at the latest version of the file.

I also have boost caching enabled, but can't see that this would be related, particularly as deleting the file fixes the issue, and re-uploading it brings it back.

Would be very grateful if anyone has any ideas!

Thanks,
Tom

Comments

gnarlytom’s picture

To Confirm, disabling boost, clearing the cache, also does not have any effect.

The offending piece of code is still present in the source.

Where the hell is it getting it from?!!!! grrrrr

nevets’s picture

Generally one should not need to override html.tpl.php, I suspect there are better ways to achieve your goal.

I would still try and disable boost caching to see if it makes a difference.

Jaypan’s picture

Are you sure you are editing the same file that you is on the server you are looking at? For example, you're editing html.tpl.php in one installation, and looking at another.

This happens.

Clearing the cache does clear html.tpl.php, so if it's not happening, it means that your problem is something else/somewhere else.

gnarlytom’s picture

Thanks for the suggestions, but still no luck.

I only have the single install on this server, so it can't be that. Also, it is strange that deleting html.tpl.php fixes this issue, so I guess this confirms that it is the correct file. But the data that ends up in the source code is just not the same as the data in the file. So it must have cached it, or moved it, or stored it somewhere else.

Any ideas where this might be?

Or perhaps even ideas on a work-around where I can add some snippets to the "head" section without using html.tpl.php ?

I only last edited the file about 3 weeks ago when a new version of our iOS app came out, so it must be something that has happened since then. Very strange.

nevets’s picture

cfox612’s picture

Have you checked to ensure there are not multiple html.tpl.php files in various locations? Such as one accidentally made it's way into a css folder or something?

gnarlytom’s picture

The issues has now spontaneously fixed itself.

There are no duplicated of html.tpl.php anywhere.

Very strange. The only thing I can think is that there is some bug in the timestamps, and thus the updated version of html.tpl.php was not being properly cleared because ?maybe the timestamp was set in the future.

I am thinking this may be the case because I have recently moved to Australia from the UK, and now am 11 hours ahead. Really don't know why this happened but 36 hours later it is fixed. Woo!

Thanks for all your suggestions,

Tom

mitzilamb’s picture

I updated my file (page--front.tpl.php) once this morning and it took the changes just fine. Then all my subsequent changes (only minutes later) have not been successful. I have tried endless methods to clear my cache (https://drupal.org/node/337176). I have even deleted my file (page--front.tpl.php) from my theme directory AND the page still shows up with the outdated code. Any help is greatly appreciated.

Jaypan’s picture

Do you have a server caching system such as memcache set up on your server? If you delete/rename the file, then clear your cache, and the file is still showing up, it means one of three things:

1) You have renamed/deleted the wrong file. For example you deleted a local file, but are looking at the site on the server (or vice-versa).
2) You have a caching system like memcache on your server, and it is serving you cached pages. If this is the case, disable the caching on your development server.
3) Your browser has cached the page. Hold shift and click refresh.

You only ever need to clear the cache one time on Drupal. Clearing a second time does not do anything. So if you have cleared it once and are still seeing the data, then your issue is one of the three above.

federico’s picture

I have the same issue. I've added custom code to html.tpl.php but the changes are not reflected.

I've cleared caches:
- Disabled the theme and enabled it again
- admin/config/development/performance > clear all caches
- "drush cc all"

I even added the code using https://www.drupal.org/project/add_to_head and it's not working.

Thanks!!!

federico’s picture

One hour later, changes have taken effect. What's the issue here?? Is there anyway to immediately clear the cache??

othermachines’s picture

Just wanted to note that I had a similar problem on a Windows machine that was resolved by restarting all services in WampServer. I could modify template.php, upload the changes, and they would be there on the server, but none of my changes were being served up locally. Obviously some kind of caching error that was cleared up easily with a restart.

Zainab_d’s picture

That worked for me, I'm on MAC, working on Lando server using Drupal 7. 

hugronaphor’s picture

In my case, the problem was the OPcache.
You can have OPcache on Live, but on development - it will cache the output.
So it's not related to any Drupal-specific thingy.

Hope this will help others.

SalAG’s picture

I had struggled with this for the last two days. I discovered the system administrator had recently installed opcache but he only knew to restart the server.
I finally found the opcache.validate_timestamps setting, which was different in a few locations, so I could test it. Turn it ON, and the caching issue for php files goes away.
Hope that works for you.