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!

Georgi Angelov
  • 4,338
  • 12
  • 67
  • 96

2 Answers2

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.

Zestfule
  • 38
  • 6
  • 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. – Georgi Angelov Jul 31 '14 at 19:40
  • 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. – Zestfule Jul 31 '14 at 21:39
  • 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 – Georgi Angelov Jul 31 '14 at 21:40
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" />
Loïc
  • 11,804
  • 1
  • 31
  • 49
  • Yeah tried that but the problem is that the framework, Symfony2, is injecting the css into the dom as opposed to linking it. – Georgi Angelov Jul 31 '14 at 19:39
  • Then your cache is on symfony2, not in the browser. check this : http://stackoverflow.com/questions/14538681/symfony2-loading-css-files-without-cache – Loïc Aug 04 '14 at 11:02