I am linking a css file like this in my php-program:
<html>
<head>
<title>Untitled Document</title>
<link href='sa_mal_link_1.css' rel='stylesheet' type='text/css'>
</head>
If i change the css file, then the updates doesn't work. The php-program finds only the old version of the css-file. There is no other file with the same name on the pc (if i change the name of the css-file then it work, intil i want to update this one too).
Where is the old Version of the css-file coming from? some sort php-cache? How do i fix it?
Using: wampserver 2.0 + php Version 5.3.0 + Apache-server versjon 2.2.11
Sounds like your browser is caching the old page. Clear the browser’s cache, close and reopen the browser. Try again.
ctrl+F5 refrsh browser or clear cache
As long as you don't pass the css
file though php
, they are served directly by the Apache Server.
Depending on the configuration of the Apache Server (e.g. if mod_expires
is active), static elements like css, images, js files could have an an expire header that is set e.g. for a week or even a month. If this header is set the browser wouldn't request the resource anymore for that time interval if it has it in cache.
For development either disable caching in your browser or disable the e.g. mod_expires
on your development pc.
If you don't know how to clear your cashe, try another browser that you never use.
On chrome, open the inspector by right clicking the web page, then click inspect element. While the inspector is open, hold the left click button on the refresh button at the top of the screen. It will drop down a menu, this is a recent addition.
You now (while the inspector is open) have the option to reload, hard reload, and hard reload + clear cashe.
This is really useful while you are working on the web.
There is also an option in the inspector of chrome that will always clear your cashe and reload anytime you reload while the inspector is open. That is how mine is set up.
If you want to do that, then click the gear at the bottom right of the screen, then in the general tab, it's the "clear cashe on refresh" box.
Above answers are correct, but if those answers aren't enough (which can also be solved by hitting CTRL + R), try disabling the cache in your .htaccess file. If you don't have one, open notepad, and type Header add "disablevcache" "true", and save it as .htaccess into your root folder. Refresh a few times with CTRL + R, should work.
EDIT
What I mean by "aren't enough", is that the cache might not be the browser, but in fact your server. You should try all of the all answers suggested to see which one works best :)