1

My CSS is linked in my head tag underneath the title tag like this:

<link href="css/main.css" rel="stylesheet">

I was working with the styles yesterday and it was applying the styles well.

Today i am adding new styles and they are not working with the PHP file, it still has the css from yesterday when i check the page source even though i have changed the css file.

What has happened?

4
  • What's in your PHP file? Commented May 6, 2015 at 19:55
  • 2
    Try a hard reload (open your browser console, right click on the refresh button, and select "Hard Reload" or "Empty Cache and Hard Reload") Commented May 6, 2015 at 19:57
  • The PHP is used further down the page inside a div to show a gallery. Commented May 6, 2015 at 19:57
  • The hard reload worked!! Commented May 6, 2015 at 20:01

1 Answer 1

4

Hard reload is the correct fix here (CTRL+R in Chrome, similar in other browsers).

You can also fix the issue forever by appending your link to the css file with a query variable that changes, say, every day so that browsers will only cache the css file for a day.

<link href="css/main.css?date=<?php echo date('Y-m-d'); ?>"> rel="stylesheet">
Sign up to request clarification or add additional context in comments.

2 Comments

Adding the date as the query string is pretty genius. I've been using a config variable and manually managing my versions in the variable. Looks like I'm switching all of my applications to something of that nature.
Just noticed, the href wouldn't have worked as it was; now corrected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.