Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Before we start: I'm a noob.

I'm trying to access YQL to get some information. Grabbing it using PHP's file_get_contents is simple enough, but it seems like either the client's ISP or the server is caching the response. To illustrate the problem, try loading:


Refresh that page a couple of times - notice that the 'created' string doesn't change - it should be a couple of seconds off each time you refresh, like this test sample:


Now my question is, is this some sort of trick by the sysadmin to cache things, or something that the ISP do? Can I get around it? I must access the YQL via URL because I need to be able to parse it.

(The sysadmin is difficult to reach)

Thanks in advance.


I've found out how to get around the cache. You can either randomize string and use the trick mentioned by @Coops below, or use the code here. Most of the times, you can skip the cache by sending Pragma: no-cache header, create a context and use it:

// Create a stream
$opts = array(
    'header'=>"Accept-language: en\r\n" .
              "Pragma: no-cache"

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('');

I still can't figure out whether the cache is configured by sysadmin or the ISP though.

share|improve this question
a general tip, you can add "?blah" on the end of the URL to make it a dynamic request and avoid some browser caches. Also I've used a javascript function in the past to append a random number on the end of the request to some google APIs, as they cache a lot. – Coops Mar 3 '11 at 10:22
@Coops - that's a neat trick! Thanks! I've figured out how to do it the other way though, I'll edit the question in case someone happens to have the same problem. – rickchristie Mar 3 '11 at 10:26

You can check some specific headers from responses: Age, Expires, ETag, Via. Values of this headers can help you to determine whatever you need. For details and header descriptions see section Responses in List of HTTP headers.

For example, value of Via header can tell you that response was received from Proxy which can have requested by you data in his own cache.

share|improve this answer
agree - have a good look at the headers or maybe post them up here. wget --spider -S – James C Apr 21 '11 at 12:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.