How clear Apache cache?

I’m getting a weird situation where even though I updated an image in a folder for a website in apache, it’s still showing the old image. And yes, I checked it in multiple browsers and on diff. computers. (Apache is in a virtualbox OS) Here’s what I’ve done:

  1. Checked it in firefox on the host, cleared cache, reloaded
  2. Restarted apache
  3. Checked it in konqueror for first time, still showing old version
  4. Checked it in the actual file folder and it’s correct there
  5. Checked it for first time on virtual machine’s OS in its firefox, and it shows the wrong/old image

Any ideas?

Apache has no cache, it’s normally your web browser or any proxies in between. Often a new file is not served because the modification date is older than the file it replaced.

No, that’s impossible here because when I loaded it into konqueror for the first time ever (I’d never visited the site or viewed the image in konqueror before) it showed the old image! So the old image was still being served up by apache.

And apache does have some sort of cache: Caching Guide - Apache HTTP Server

That’s only if you have set it up. Out of the box Apache does not have a cache. You can look at the logs in /var/log/apache2 to see if the request was served by a 200 reply or a 304 not modified reply. It could also be a simple typo, you put the new file in the wrong directory or under a different name.

Well then what’s causing the image not to refresh/change? I tried everything: cleared the whole cache in firefox. Tried viewing the image directly in the browser (not in a web page but straight to the image url) and refreshing. Nothing changes it!

The only way I’ve been able to get it to change the image is to change the name of the image, reload the web page and then change the name back and reload again and then I get the image.

Is there a proxy between you and the web server? Even one you might not know about, like an ISP’s “transparent” proxy.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Where is the website? This could easily happen with a proxy server
somewhere on which you do not plan. For example, if your website is
outside your network any number of devices between your computer and the
web server could cache pictures for you. Similarly if your server is in
your network but your system or browser is configured to use a proxy
server then that proxy could be “helping” you or your organization. Using
a Firefox plugin like Live HTTP Headers (or getting a LAN trace if the
traffic is not encrypted) would probably show this fairly well.

Either way, ken’s right; Apache doesn’t cache by default.

Good luck.

On 09/01/2010 06:06 PM, 6tr6tr wrote:
>
> The only way I’ve been able to get it to change the image is to change
> the name of the image, reload the web page and then change the name back
> and reload again and then I get the image.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJMfvGlAAoJEF+XTK08PnB50dEP/01SYM44BfK3l1d/f4SQSFXL
n7nL00YPsXwZxHazVEmyOlEyYYMzwgbUCf6QXK7nQsb7S8A4rFBN3McgS59NDooZ
mJ/LeMoCAAkFZM1D4KKU5LH7W59UXQi5g2ljnaDQ6KLzUwKISdeIrAjvNm9a2mcr
GlZe5R8GymC4/bc/PJLICnCBzQT/0xV+ScMzvu7CmyZ4UgJqBy9eHpwgZ+vAfnPd
5uKj/sBhOr0OqAa5QkZReUy6kES9WHHvR9q+++50mwvEJAMP4hLqUkgWG2RztIxF
xs3TgjIYKpO9oC8EGdkHAkp5A6GRib0CDrchJh6/pmM0wXfZgJaXSZ3QP/nuadUU
TDkQJ/b8kQStE03BjY8DaYQHc7mqfezUU+7zNzowSkBViJ6Up8imA8JKNKsDqwLF
ZNbrET1M+4RU1ki1gEjrDcC2keFtUsiCqNtVcYk6Vtth1jCH+e42ajutfCSks4+f
ElXYbIpP1qaqZBlN0BVkuQst5uetPWfxP8jWk0dlB5ITzDKqFCaAILX/SbgHbvtO
9XDtCnROFKkReccTgDq/PAjfTIgouPpubAiu0f9siaHKsq5R8TEMagA5PFLl70nT
ucw+CFRTQx47D+lHntlSCERe2L4r/XQRAODh1zhySzzUqQjs7staorT05A/iyEMl
y4w2jgKo4dut3eofQNSL
=8+xN
-----END PGP SIGNATURE-----

No, the website is hosted locally in an Ubuntu LAMP setup inside VirtualBox. So I’ve viewed the site both on the host computer and inside the virtual machine and both show this issue.

Still getting this issue.

Dear 6tr6tr,
I know this thread is old but thought that a solution would be nice to have so here it is
I had the exact same problem and yes apache is cacheing the images !
I would delete the file from the vboxsf then clear the cache from the browser then check in the server directory that the file was not there
then reload the page and it was still there. How i know it was in the server well i was able to download it from the browser to my desktop.
What was mind boggling was that updates to the php html or any other parsed file format worked just fine.
I looked further into the issus and found that apache has a glitch with network mounted folders of NTSF format. Something to the effect that non-parsed elements are sent to the browser and since the file format and permissions on the network drive were incapatible makes apache cache some how. So we want apache to stop processing these elements and force it to read them each time they are requested.
—>add this to the bottom of the file /etc/apache2/apache.conf

#Disable image serving for network mounted drive
EnableSendfile off

Hope that helps

Thank you very much! This solved my problem. We have roughly the same setup. I’ve been working on this for days. Thank you very very much! You’re saving me much time!

My setup is Windows XP, with CentOS running on a VirtualBox. The PHP files I’m working on is on Windows XP but they’re served by CentOS, because I need the APE (Ajax Push Engine) and it doesn’t work on Windows. Basically, the files being hosted by httpd is on a Windows NT File System. After removing the comment on EnableSendfile off on my httpd.conf file, it started de-caching things.

Once again, thank you.

Cool thanks!

I have it too. All this talk about “it must be on your ISP” is nonsense. Like you, it is a local copy on my laptop, I have even pulled out the cable to the router, so the old images are stored on my laptop somewhere. I changed the directory name (and in the PHP code too) and it loads the correct images, but as soon as I change the directory back to the correct name (and the code) it finds the old images again! (No cache eh? well explain where they ARE held).

In my case, I do have network drives not involved in this instance. Apache and the site are on my local C: drive. I tried your fix jusr in case but it didn’t help.
My files are slightly different, I have two config files, but I changed both
C:\wamp\bin\apache\apache2.4.9\conf\wamserver.conf
C:\wamp\bin\apache\apache2.4.9\wamserver.conf

Please gentleman This thread is almost 6 years old!

Not very many people will still follow new posts here. Also I assume that all software involved in the mean time changed to newer versions.

So please, when you have a problem, start a new thread in the most appropriate forum with a good telling title. That is realy the best way to draw the attention of the people here, including those that might be able to help you.

This thread is CLOSED.