if reqeusts is called in while loop, it always return same value even if data has been updated in database.

Summary.
if reqeuests is called in while loop, it always return same value even if data has been updated in database.

the request content is:
"res = json.loads(requests.get(url, data, verify=False).text)"

after stop the call to test_deposit and call again the return value "res = json.loads(requests.get(url, data, verify=False).text)", then the value was updated

## Expected Result
the return value of  res = json.loads(requests.get(url, data, verify=False).text) should be updated immediately because of the value in database has been updated.


## Actual Result
the return value of  res = json.loads(requests.get(url, data, verify=False).text) always be same even if the value in database has been updated.


## Reproduction Steps

```


   def test_deposit(self):
        receipt = self.kovan.send_ether_to_contract(0.0001)
        self.assertEqual(receipt['status'], 'added', "充值交易进入区块成功")

        txn_receipt = receipt['txn_receipt']
        block_number = txn_receipt['blockNumber']
        print(txn_receipt)
        print('first block is:' + str(block_number))

        # 轮询6个区块来测试着期间充值不到账
        # current_block_number = self.w3.eth.blockNumber
        balance_before_deposit = self.test_get_balance()
        print('before is:' + str(balance_before_deposit))

        count = 0
        while self.w3.eth.blockNumber < (block_number + 16 - 1) and count < 30:
            print(self.w3.eth.blockNumber)
            # # test_get_balance缓存清理
            # cache_info = self.test_get_balance.cache_info()
            # print(cache_info)
            # self.test_get_balance.cache_clear

            # balance_after_deposit = self.test_get_balance()
            # print(balance_after_deposit)
            url = self.prefix + 'balance'
            data = {
                'address': self.wallet_address
            }
            # res = self.run.request(url, 'GET', data=data)
            res = json.loads(requests.get(url, data, verify=False).text)

            self.assertIn('Success', res['message'], "测试成功")
            balance_after_deposit = res['data']['result'][0]['tokenAmount']
            print('after is ' + str(balance_after_deposit))

            self.assertEqual(balance_before_deposit, balance_after_deposit, '未经过6个区块充值不应到账')
            gc_status = gc.isenabled()
            print(gc_status)

            # 内存释放
            del balance_after_deposit
            gc.collect()
            time.sleep(10)
            count = count + 1

        print('到账时间总计花费：' + str(count * 20))

        # if self.w3.eth.blockNumber >= block_number + 6 - 1:
        #     balance_after_deposit = self.test_get_balance()
        #     if balance_after_deposit >


```

## System Information

    $ python -m requests.help

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.6"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.6.5"
  },
  "platform": {
    "release": "17.4.0",
    "system": "Darwin"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.18.4"
  },
  "system_ssl": {
    "version": "100020ff"
  },
  "urllib3": {
    "version": "1.22"
  },
  "using_pyopenssl": false
}
```


Unless I'm missing something, I don't see you update the value of `data` or `url` in your while loop.

I'm not sure what framework you are using but if you have an instance of a record and that record is updated in the database, you probably need to fetch the object again to get the updates.

That being said, where in the while loop are you updating anything in the database?

Hi @FrancisJen, this is an issue with your server setup. Either something isn't being communicated to update the database as you're expecting, or your server isn't updating the response how you'd expect. As @colinfike pointed out, you may not be updating your requests as you're expecting to, so I'd suggest reviewing your code.

A very simple POC shows that Requests will update the response without issues. We don't do any cacheing and only relay what the server has sent to us.

```python
import requests
import time

while True:
    r = requests.get('https://now.httpbin.org/')
    print(r.json())
    time.sleep(1)
```

I'm suffering exactly the same problem.  I'm hosting content on Github (configuration data), and requests fetches the current raw data just fine upon starting the program fresh.  But, if I git commit && git push to update the configuration data in the repository, then instruct my program to refetch the data hosted in Github, it gets *exactly* the same data it first fetched when the program was first launched.  Nothing I can do, save restarting my program, can cause it to get the most recent data.  Meanwhile, using `curl -X GET` to retrieve the same resource on Github returns the properly updated information.  By process of elimination, requests is the only component which seems responsible for this caching behavior.

Somewhere, somehow, requests is caching data.  This cache needs to be exposed so that we can somehow flush its contents under program control.  

Hi @sam-falvo, Requests doesn’t really have a mechanism to cache content. The example that was provided above shows we will update inside of a while loop if the response content from the server changes. It’s possible you’re being routed to a server side cache by github.

We’ll need a minimal poc of how you produced this and the same poc with curl. It would also be helpful if you can provide the output of `pip freeze`. Do you have anything like `cache-control` installed?

Should I open a new ticket with this information, or can I re-use this one?  Thanks for responding so quickly.  :)

@sam-falvo also check that you're not being redirected as part of the process and running into the `redirect_cache`

(That's the only cache we have)

@sam-falvo You can see if https://github.com/requests/requests/issues/2409#issuecomment-70159804 fixes this for you

@sam-falvo Ian is correct, this is likely a redirect from Github. If you can confirm you’re not receiving a redirect though, feel free to open a new issue with more details.

It is not a redirect from Github.  As mentioned earlier, I used curl and it
delivers the updated content.

I am trying to create a POC for this issue, but am so far not successful,
which is frustrating to me, since it **literally** is the same code as my
production code, sans handlers for my production work.  I don't understand
how code that has *zero* to do with configuration has any influence at all
on whether request('GET', ...) returns the same content.  This is extremely
frustrating, and without visibility into why this is happening, I no longer
have anything to go on.

On Tue, May 15, 2018 at 4:02 PM, Nate Prewitt <notifications@github.com>
wrote:

> @sam-falvo <https://github.com/sam-falvo> Ian is correct, this is likely
> a redirect from Github. If you can confirm you’re not receiving a redirect
> though, feel free to open a new issue with more details.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/requests/requests/issues/4639#issuecomment-389341012>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABbP-K3JDYNsinioTDqyrikpzbQ3vJsaks5ty16LgaJpZM4T5SyZ>
> .
>



-- 
Samuel A. Falvo II


@sam-falvo This absolutely sounds frustrating. Unfortunately, there doesn't appear much for @nateprewitt or myself to do to help you without looking directly at your code and seeing the curl request you're making.

I can suggest that there is some logging that you can enable which will cause urllib3 to log details. That might offer you some insight into what may be happening.