As you know applications like gmail / yahoomail they constantly keep changing their js/css and when you login you dont have to clear your browser cache to see the new changes, they are automatically shown to you.

How do they do this? I see there are two approaches:

1) in your code where you specify the path of the js/css you append time with a querystring that will force your browser to load the lastest js/css no matter it has been modified or not.

2) You use the "Pragma: No-cache" Tag in your page.

But the problem in these approaches is that your application makes an HTTP request every time its called since it assumes the file is new.

So whats the solution?

Any help is appreciated.