0

So I am trying to figure out why my localhost app looks different when accessed from another computer, as opposed to the way it looks when I am accessing my localhost directly from my machine.

I am using a WAMPSERVER and I have a PHP app. It seems like when I try and change the CSS of the app, only I can see the changes. When I try and access the app through another machine, by accessing my localhost, the app looks different and some of the styling is the old styling. Also, if I change anything in the HTML, it updates correctly, but I cannot seem to be able to change the CSS - almost as if the network cached the CSS and it won't update it anymore.

I tried:

  1. restarting the WAMPSERVER
  2. clearing browser cache
  3. restarting the PC
  4. Flushing DNS cache ( ipconfig /flushdns )

Nothing seems to be working and the only way I can affect the style of the page is by adding inline CSS which is a pain in the butt and I do not want to do that.

Any suggestions will be highly appreciated!

2 Answers 2

0

If you're using a PHP Framework (Zend, Symfony, etc.), many of them incorporate caching of their own and since you're not accessing the site from a local address it's automatically using the cache, you may need to clear the cache of the framework specifically.

Sign up to request clarification or add additional context in comments.

3 Comments

I tried that but it doesn't seem to make any difference. I use Symfony2 and I cleared the cache but it did not make any difference.
Did you make sure you clear both the prod and dev cache? I was having the same issue and I think it stemmed from it was because I was only clearing the dev cache and it automatically loads production when from a non-local address. I think to be extra thorough you can just delete the entire cache directory.
Yeah I deleted all cache. I actually realized that if I do not do localhost/app_dev.php , it will just load the prod version which has the messed up css. If I manually say /app_dev.php , everything works fine. Now I need to figure out why it is not redirecting to app_dev.php automatically
0

Browsers cache things, and that can be boring.

A way to prevent that is to add a random string in the url where you get your CS, JS, or whatever, like that :

<link href="mystyle.css?t=<?php echo time()?>" rel="stylesheet" type="text/css" />

2 Comments

Yeah tried that but the problem is that the framework, Symfony2, is injecting the css into the dom as opposed to linking it.
Then your cache is on symfony2, not in the browser. check this : stackoverflow.com/questions/14538681/…

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.