Why aren’t changes to php files reflected immediately on my site?
-
Hi – When I make changes to my php files, header.php for instance, there seems to be a time delay of several hours or so before the change is reflected in my site. I use Yahoo web hosting. I am not sure if this issue is related to Yahoo or to WordPress. Change to Stylesheet.css are reflected immediately but not the changes to header.php. Weird.
Can someone explain to me why this happens? Thanks!
-
I gotta say I can’t see this being a wordpress issue. I’ve used it on several hosts, and never had an issue like what you’re describing.
Are you running any sort of cache system or plugin?
I’m new to WordPress but I dont believe I am running any plugins. I took the “Pool” theme and copied it to my own custom theme. I am now trying to edit this theme to have the look and feel of the rest of my site. So far, I am making changes only to stytesheet.css and header.php. Changes to Stylesheet.css are reflected immediately. But changes to header.php seem to take hours before they propogate. I have cleared my browser cache so its not that.
Thanks
I had this same problem. In a word, it’s cache.
Try adding this line to your wp-config file:
define('DISABLE_CACHE', true);
This line, IMHO, should be there by default, prefaced with the following comment:
When cache is ENABLED, updates to theme source files are not immediately displayed. This can result in errors, frustration and confusion while attempting to customizing a theme. Keep cache DISABLED until you are finished any customization work. To ENABLE cache, comment out this line.
Thanks for the advice. I also have the same problem (I use Yahoo also.). I never experienced this problem until I started using WordPress, so I assumre this is a WP issue. I will try the above solution.
The average person doesn’t need the built-in cache, and it shouldn’t be affecting the theme rendering at all from what I know. WP-Cache, on the other hand, can be useful, and DOES affect caching of all site pages and needs to be turned off while you work on theme code.
CSS files are generally ignored by the whole process, and thus can be updated at will, though you sometimes need to refresh twice to get the browser to pick it up.
-d
I agree with the previous posts about disabling WP caching whilst working on the site, but I would like to add that the Yahoo (and a number of other large hosting providers) employ dynamic content caching systems globally load balanced, — english translation, they store you’re php output as “html” in a caching appliance at various sites globally in order to reduce overall network traffic for duplicate requests, you might also consider “pragma-no-cache” headers, in order to avoid the caching servers/appliances completely, at least while working on the site.
One of the “quirks” of most of the caching systems used by the Yahoo’s/Aol’s, etc of the world is that they generally work very well with things like the “timestamp” or time modified on html files, and so will reload them almost immediately upon seeing timestamp changes, ironicaly, dynamic content from php files get caught in a “loophole” in that system, so it can take some time before the cache “reloads” the content. css files are treated as html files with regards to time modified, so will reload almost immediately upon changes.
Almost all large hosting providers AND ISP’s are using some type of caching or other these days (I’m on a comcast cable modem, and they use caching extensively, fortunately (for me), it ignores most dynamic content), AOL is about the worst, yahoo is probably somewhere in between.
I use CI-HOST for hosting a couple of dedicated servers and co-location, I’ve been with them for around 6 years, and they’re really great. They too, “optimize” thier network with caching however. So, my point is, that it’s almost impossible today to avoid having your content cached somewhere (especially images).
For sites where I’m either doing lots of work, or I want to ensure users are getting fresh content, I use some/all of the following –
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
and/or
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
and/or<META HTTP-EQUIV="EXPIRES"
CONTENT="Mon, 22 Jul 2002 11:12:01 GMT">So, as I mentioned, while wp “caching” could and likely is part of the issue, the various caching servers also have an impact as well. It’s worth noting, that if you’ll be using any of the meta tags, the “pragma” tag from HTTP/1.0 has more or less been depreciated by the “cache-control” tag in HTTP/1.1, so for most caching servers that would be the more effective and preffered method of controling how/if your content is handled.
Part of the issue with the caching servers at the moment, is that your php generated content is handled differently than a “known” file type like .jpg, .htm, .css, etc. The caching servers basically store your php generated content as something like
http-your-url-content-php.htm
I have some previous experiance with caching and load balancing, and this all really became apparent to me in the past year or so as I had a number of AOL users contacting me saying, I made a post and keep hitting “refresh” or “reload” but I my post doesn’t show up for hours.
If anyone needs/wants any further detail on the caching server process employed by the web hosting/isp companies, feel free to contact me at chradil at comcast dot net with your questions.
Thanks for all the help. I really appreciate it!
One response to my original question was to try adding this line to my wp-config file:
define(‘DISABLE_CACHE’, true);
I found a file at the root of my blog and I made that change to the file, but it doesnt seem to have fixed the problem. When I make a change to header.php, I still do not see the change reflected immediately.
So my questions are:
-Was this the correct file to make the change in? Because I also see a file called “wp-cache-config.php” inside the “Content” folder. Maybe that is where the change should be made?
-If it is the correct file, do I leave this line unchanged?define(‘WP_CACHE’, true); //Added by WP-Cache Manager
Thank You
WP-Cache is a plugin, and a COMPLETELY different system from the internal WP caching, as I tried to explain above.
WP’s ‘object’ cache should NOT affect changes in PHP updating immediately, whereas it would affect certain queries to the database.
WP-Cache on the other hand DOES affect high-level page loading and code loading. As I said, if you have it active and are working on theme stuff, just disable it for a little while. But do so from the dashboard/options, not in any php files…
-d
OK, I get it now. I disabled WP-Cache from the dashboard/options and my header.php changes are immediately applied. Thanks!
- The topic ‘Why aren’t changes to php files reflected immediately on my site?’ is closed to new replies.