ioan
ioan

Reputation: 295

Weird Ghost CSS Bug

How is it possible that my whole website works normally without the css file with all the styles? I have this line in the header:

<link rel="stylesheet" type="text/css" href="styles.css" />

I deleted the only styles.css file from the server, but nothing changed. If I delete that line from the header then there are no styles (as expected)

At one point I noticed that none of the css changes I make have any effect, so I made sure that i'm not doing something dumb like editing or referencing the wrong file and that there are not 2 copies of it for some reason. If I change other html files, then I can see the effects, but not the styles file.

I can force it to work by renaming the css file, but I don't really want to do that.

Has anyone seen this happen before?

Upvotes: 0

Views: 262

Answers (1)

Mahesh G
Mahesh G

Reputation: 1276

This is because caching of the CSS. So try clearing the cache of the browser.

You can prevent the CSS caching by below way

<link rel="stylesheet" type="text/css" href="style.css?v=1" />

Using PHP you can do this trick

<link rel="stylesheet" type="text/css" href="style.css?<?php echo date('l jS \of F Y h:i:s A'); ?>" />

Upvotes: 2

Related Questions