How to prevent browser caching

I am developing facebook applications. I am really annoyed by chance when I change the CSS stylesheet / add to javascript function. The browser does not reflect changes at all. This is very annoying because I never see the changes I just made.

For instance. I changed the CSS stylesheet, so img1 moves from 100 pixels to 50 pixels. But in firfox / chrome img never moved.

I added the javascript a () function to one of my script. But the browser console keeps telling me that () is undefined. I checked the codes 10 times and there are no errors.

Can someone tell me what the problem is here and how to solve it?

I use my mac as a btw hosting server

thank

+3
source share
2

, , , GET:

<link rel="stylesheet" type="text/css" 
      href="http://cdn.sstatic.net/stackoverflow/all.css?v=4fd8a9d8937d">

, , - :

PHP ( filemtime - ):

<link rel="stylesheet" type="text/css" 
      href="http://cdn.sstatic.net/stackoverflow/your_css_file.css?v=<?php echo filemtime('/your_css_file.css'); ?>">

Ruby ( File.mtime, ):

<link rel="stylesheet" type="text/css" 
      href="http://cdn.sstatic.net/stackoverflow/your_css_file.css?v=<% print File.new("testfile").mtime.to_time.to_i('/your_css_file.css'); %>">

, , .

+5

js/css , , - :

<link rel="stylesheet" href="css/screen.css?<?php echo time(); ?>" media="all" 
type="text/css" /> 
+3
source

All Articles