{"action":"opened","issue":{"url":"https://api.github.com/repos/ionrock/cachecontrol/issues/77","labels_url":"https://api.github.com/repos/ionrock/cachecontrol/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/ionrock/cachecontrol/issues/77/comments","events_url":"https://api.github.com/repos/ionrock/cachecontrol/issues/77/events","html_url":"https://github.com/ionrock/cachecontrol/issues/77","id":73103147,"number":77,"title":"When are contents written the path returned by url_to_file_path [question]","user":{"login":"ElDeveloper","id":375307,"avatar_url":"https://avatars.githubusercontent.com/u/375307?v=3","gravatar_id":"","url":"https://api.github.com/users/ElDeveloper","html_url":"https://github.com/ElDeveloper","followers_url":"https://api.github.com/users/ElDeveloper/followers","following_url":"https://api.github.com/users/ElDeveloper/following{/other_user}","gists_url":"https://api.github.com/users/ElDeveloper/gists{/gist_id}","starred_url":"https://api.github.com/users/ElDeveloper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElDeveloper/subscriptions","organizations_url":"https://api.github.com/users/ElDeveloper/orgs","repos_url":"https://api.github.com/users/ElDeveloper/repos","events_url":"https://api.github.com/users/ElDeveloper/events{/privacy}","received_events_url":"https://api.github.com/users/ElDeveloper/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-04T19:15:37Z","updated_at":"2015-05-04T19:15:37Z","closed_at":null,"body":"I'm able to retrieve the path where contents will be written by a FileCache object, however as the function's docstring indicates there's no guarantee that this file will exist. What I'm finding is that for most URLs I try, the contents are written immediately as I perform the request, see the two examples below.\r\n\r\nWhen I do the following, the path doesn't exist:\r\n\r\n```python\r\nIn [54]: from cachecontrol.caches import FileCache\r\n\r\nIn [55]: from cachecontrol.caches.file_cache import url_to_file_path\r\n\r\nIn [56]: from contextlib import contextmanager\r\n\r\nIn [57]: from tempfile import gettempdir\r\n\r\nIn [58]: file_cache = FileCache(gettempdir())\r\n\r\nIn [60]: from cachecontrol import CacheControl\r\n\r\nIn [61]: sess = CacheControl(requests.Session(), cache=file_cache)\r\n\r\nIn [62]: url = ('http://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?retmax=1'\r\n   ....:        '00&retmode=text&tool=skbio&db=nucleotide&id=459567&rettype=fas'\r\n   ....:        'ta&retstart=0&email=foo@bar.com')\r\n\r\nIn [63]: req = sess.get(url)\r\n\r\nIn [64]: cached_fp = url_to_file_path(url, file_cache)\r\n\r\nIn [65]: from os.path import exists\r\n\r\nIn [67]: _  = req.content\r\n\r\n# the file doesn't seem to exist\r\nIn [68]: exists(cached_fp)\r\nOut[68]: False\r\n```\r\n\r\nHowever, if I try this with another URL that has the same contents, the file exists.\r\n\r\n```python\r\nIn [69]: other_url = 'https://gist.githubusercontent.com/ElDeveloper/e0144eaf196f3a641409/raw/f14a6ff47b880537da3067b322526a91124ff742/-'\r\n\r\nIn [70]: req = sess.get(other_url)\r\n\r\nIn [71]: cached_fp = url_to_file_path(other_url, file_cache)\r\n\r\n# the file exists YAY :D\r\nIn [72]: exists(cached_fp)\r\nOut[72]: True\r\n```\r\n\r\nI don't know if this is something specific to the server I'm trying to retrieve the data from or if this is an expected behavior of FileCache. Any help is greatly appreciated."}}