Forum Moderators: phranque

Message Too Old, No Replies

Apache pages sticking / serving wrong page

         

EricS

6:25 pm on Dec 31, 2009 (gmt 0)

10+ Year Member



I have a bunch of php pages that I'm serving up with Apache. Randomly, a page gets stuck. The way I had it, they all included header.inc.php to have a uniform header. That page is executing, because it traps the filename from the server and includes it in the top of the page. Even when a page gets stuck, it has the right file name in the page. I tried removing the include for that header.inc.php, but the rest of the page still got stuck.

What I mean is, if I jump from one to the next to the next, and back, over and over, eventually Apache stops serving up the new page, and just keeps resending the same page. Even if I switch browsers. Even if I telnet localhost 80 and GET it directly, it still serves teh stuck page, not the requested page, so it's not on the browser side. access.log shows the right page being requested, and there's nothing in error.log. It seems to think it's sending the right page, but it sends the wrong page. If I reload the stuck page, then try a different page, it starts working again.

I tried commenting out of httpd.conf:

LoadModule cache_module modules/mod_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so

But it didn't help. I've tried it with and without in php include to header.inc.php, and it's not happening on the browser end. Anyone have any experience with this?

jdMorgan

10:08 pm on Dec 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What does a 'page' URL look like, and what would a 'next page' URL look like?
Are sessions, cookies, or 'dynamic URLs' with query strings used on this site?

Jim

EricS

1:11 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



Thanks, jdMorgan.

URL's like:
http://host.ip.addr/db/add.php
http://host.ip.addr/db/update.php
http://host.ip.addr/db/search.php

Add and update have cookies. Search doesn't. All that gets cookied is username. This happens without any GETs to dynamic query strings. They all use a PHP include for a "header.inc.php" page, but it happens even if I disable that.

[edited by: jdMorgan at 2:47 pm (utc) on Jan. 4, 2010]
[edit reason] de-linked. [/edit]

jdMorgan

2:06 pm on Jan 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I asked what a 'next page' URL looks like because you stated:
What I mean is, if I jump from one to the next to the next...

So that's still not clear.

However, in addition to that line of thought, another has popped up since you last posted: Try firing up the "Live HTTP Headers" add-on for FireFox/Mozilla and look at your server responses with an eye toward "What do public (network) caching proxies see as regards Cache-Control, Expires, Etag, Last-Modified, and server status response headers in your server responses?" If Firefox also shows this 'stuck pages' behavior, then the results reported by the LHH add-on should be valid.

The point here is that you may be looking at your server through a network proxy that caches pages. Since network caches use the 'public' Cache-Control scope while browsers use the 'private' scope, and since you've reported that forcing a page reload clears the problem but switching browsers does not, *and* that you've disabled server-side caching to no avail, the only place left to look is at the in-between space, which would include caching proxies in the public network -- for example, ISP-edge and corporate-network caching proxies.

There are a few inconsistencies here but rather than focus on them, it would be worth checking out the HTTP headers view of things, if for no other reason than to get a view of the problem from a different angle.

Jim

EricS

2:44 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



Thanks again, Jim. What I meant about "next page" is just jumping from one to the next. I have links in the top of the page to "add.php" "index.php" and "search.php". If I click from one to the next for a while, it eventually happens.

I think you're right that it's happening in a network proxy. But I looked at the Live HTTP Headers add-on and it didn't give me anything. When I include the PHP header() for cache control, it shows up.

http://server.ip.addr/db/index.php

GET /db/index.php HTTP/1.1
Host: server.ip.addr
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://server.ip.addr/db/index.php
Cookie: dbusername=USERNAME; navigator_sections=status.alerts.reporting; opsview_web_session=LONG NUMERIC STRING; PHPSESSID=LONG NUMERIC STRING; JSESSIONID=LONG NUMERIC STRING.node1

HTTP/1.x 200 OK
Date: Mon, 04 Jan 2010 14:38:32 GMT
Server: Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7d DAV/2 PHP/5.2.6
X-Powered-By: PHP/5.2.6
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Content-Length: 1704
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html

[edited by: jdMorgan at 2:47 pm (utc) on Jan. 4, 2010]
[edit reason] de-linked [/edit]

jdMorgan

2:53 pm on Jan 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What I meant about "next page" is just jumping from one to the next. I have links in the top of the page to "add.php" "index.php" and "search.php". If I click from one to the next for a while, it eventually happens.

Yes, but I specifically asked for examples of these because no-one here but you knows what the URLs actually look like, and a large part of server control and behavior is URL-based. But going down a different road for now...

Try modifying the PHP header configuration (keep a back-up, as this is only a temporary change for testing) to specify "private, must-revalidate" or even "no-store". After deleting your browser cache, testing should then make clear whether the caching is in the network or is still being done server-side (for some reason).

Jim

EricS

3:03 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



Oh, sorry. Just relative links:

<a href='search.php'>Search Page</a>
-
<a href='add.php'>Add Page</a>
-
<a href='index.php'>Full Index</a><br><br>

And I tried the headers:
header( "Cache-Control: no-cache, must-revalidate, no-store" );
header( "Pragma: no-cache" );

To no avail.

EricS

3:10 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



I just realized something. It actually does have to be Apache, because when it's stuck on a page, even if I'm on the web server and telnet localhost 80 then GET the page, I still get the wrong page. That shouldn't be going over any proxy, right?

EricS

3:28 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



Oh, and if I restart Apache while a page is stuck, it stops being stuck. :( I think I'm back to Apache being the problem.

jdMorgan

3:58 pm on Jan 5, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should try just "no-store" as the Cache-Control header, but I suspect the results will be the same, and that you've got a problem on the server end.

However, keep in mind that plain-old Apache without a bunch of extra modules bolted on is just a HTTP server: You ask it for a URL, it serves you the content of a file (or runs a script to generate content). As HTTP is a stateless protocol, HTTP servers have no 'memory' whatsoever of any previously-handled HTTP requests aside from the fact that these requests are logged (However, the server makes no use of these logs). Therefore the current state of the server itself does not depend on previous requests.

Adding sessions and cookie-based scripts and add-on caching modules into the mix complicates things, and the problem is most likely to be found in one of these functions. These functions *do* introduce dependencies on previous requests into the pure-HTTP-server environment. So, it was wise to disable your server-side caching as a first step, and I suggest you continue down that path for now, investigating all functions which involve previous-request and client-state dependencies. Make double-sure all server-side caching is off, and then start looking at sessions and cookies. The headers checker is useful in this regard as well.

Jim

AnyaV

6:52 am on Mar 8, 2010 (gmt 0)

10+ Year Member



EricS:

I am having the same or very similar problem. Occasionally, my php page gets stuck to the previous php page, even though the address bar shows correct address, the content is from the page that was invoked before. After few minutes, it gets "unsuck" by itself. It is very bad situation, because my clients can not reliably use the site. Did you ever found the solution to your problem? I need help.
btw, did the turning off server side caching help?

Any help is appreciated