I've been having a reoccurring issue with my VPS since I moved to a new company and I'm trying to figure out what the issue is. There are a few different things going on (I believe they are all connected) --

  1. When you visit a page that doesn't exist, instead of throwing a 404 error, it shows a page which looks like the index.php file in the respective directory you are in.
  2. The bigger issue, is that when I'm uploading new files through FTP, they are successful but when I visit the page in the browser, nothing has changed. In fact, I've tried clearing the browsers cache and I've even visited the site in three browsers (Safari, Firefox, & Chrome) to make sure it wasn't something specific to one of them. In all cases, the same (old) page displays. I've also noticed a similar behavior when you log in to the site. As it's setup you are shown a login link if you're not logged in, upon logging in, the link changes to show your username. I'mm logging in (and it's updating a timestamp on the database which is working correctly) but it doesn't show me logged in at the top of the screen. It still shows the Login option.

#1 I have no clue on so any help would be appreciated. As for #2 I am thinking the host is doing some sort of caching on their side that's causing this error? Of course, I'm no expert either so if you all have some ideas please let me know.

Specs: I'm running a Xen Linux VPS. Apache 2.2.19, PHP 5.3.6, mySQL 5.1.56, and cPanel/WHM are all installed and running.

Dani AI

Generated

A short, practical checklist for anyone who hits two related problems: requests returning the wrong page (instead of a proper 404) and new uploads/changes not appearing in browsers. later resolved their case; below are reproducible diagnostics and safe fixes others can apply to avoid the same surprises.

First, verify what the server is actually returning (status + headers) and whether a cache sits between you and the origin. From a shell try:

curl -I -L -s -S https://your.site/path
wget -qO- https://your.site/path | md5sum
md5sum /path/to/local/file

Look for the HTTP status (404 vs 200), and headers like Cache-Control, Expires, Age, ETag, Via or X-Cache. Using a unique query string (e.g. ?nocache=$(date +%s)) quickly shows whether an intermediate cache is serving an old copy.

Second, rule out opcode/bytecode and proxy caches. Common culprits are an HTTP reverse-proxy/CDN, server-side caching modules, or a PHP opcode cache. To clear an opcode cache from PHP:

<?php
if (function_exists('opcache_reset')) opcache_reset();
?>

For pages that should never be cached (logged-in views, after POSTs), emit explicit headers:

<?php
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Expires: 0');
?>

Also check webserver error/access logs while reproducing the request (tail -f), and compare the served content hash to the on-disk file. If a hosting provider or control panel manages caching, ask them to confirm and to purge any transparent caches. Finally, implement proper cache-control rules for static assets (long TTL + fingerprinting) and for dynamic/authenticated pages (no-cache), so future updates and 404 behavior are predictable.

So I’ve done a little more digging and fixed the 404 issue, it appears there was something in the .htaccess file that was causing the problem. I deleted the file completely and that’s running good now.

I’ve also been doing some testing on the cache issue. I’ve tried restarting both Apache and my VPS to make sure it wasn’t some glitch, the error still persisted. So I removed the index.php file to make sure when I was FTPing files the timestamp was updating and it is. I also created a test page (test.php) that has just some words and a php function to print the current date/time. That works and on refresh, the time updates as it should. When I put that same function however into one of my “normal” pages, I get the same error whereby on each refresh, the time stays the same.

Hopefully this update may help in identifying the problem.

I've fixed the issue! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.