0

I'm working on php/css project through localhost and nearly every time I change css and reload page, css remains unchenged until I delete cookies, cache and other site data (somethimes even then it doesn't work straight away). Css is linked correctly, as well as aeverything else, so this is not a problem with code, but with browser/cache.

My question is- is there a way to resolve this issue other than deleting cookies and cache every time I change something in my css?

7
  • 1
    Does this answer your question? Cache busting via params Commented May 27, 2022 at 6:49
  • 1
    just a quick tip: if you reload the page with ctrl + f5, the cache is cleared and changes are shown... way faster than any server side settings. Commented May 27, 2022 at 6:59
  • @AlonEitan I tried it several times, but it doesn't change anything :'( Commented May 27, 2022 at 7:05
  • @toffler thanks for the tip, I've been using it before and I just switched to ctrl+R for no reason, but I had no idea that ctrl+F5 clears cache. Anyways, it doesn't change anything Commented May 27, 2022 at 7:07
  • If this doesn't work, you can add a "changing" param to the include of your css in php... something like ".../file.css?v=".time()". If it is still not working, it might be not a caching problem Commented May 27, 2022 at 7:11

2 Answers 2

3

Please add a query parameter to CSS with dynamic file modified time:

<link rel="stylesheet" href="style.css?v=<?php echo filemtime("style.css");?>" />
Sign up to request clarification or add additional context in comments.

Comments

0

All the comments and answers were helpful, but none of them solved the problem long term.

After some experimenting, I found an answer: disable saving cookies and cache for given site, in

chrome settings > advanced > Privacy and security > Sites that can never use cookies

Comments

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.