curl检索旧版本的page
curl retrieves old version of page
我正在使用curl在我的bitbucket存储库中获取一个HTML文件。我不能给你直接的链接,因为回购是私人的,但它来自以下形式:https://bitbucket.org/uname/project/downloads/index.html
我使用以下代码:
mCurl = curl_easy_init();
curl_easy_setopt(mCurl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(mCurl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(mCurl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(mCurl, CURLOPT_URL, String::toAnsi(address).c_str());
curl_easy_setopt(mCurl, CURLOPT_WRITEFUNCTION, _internal_curl_write_callback);
curl_easy_setopt(mCurl, CURLOPT_WRITEDATA, this);
curl_easy_perform(mCurl);
虽然一开始,在我更改页面(在repo上删除并上传新页面)后,结果似乎还可以,但即使我重新启动应用程序,curl仍然会检索页面的旧版本。但是,在浏览器中,如果我输入该链接,就会得到新的链接。
curl中有我可以禁用的缓存吗?或者你知道这种行为的其他可能的解释吗?
若要从服务器请求非缓存页面,请设置标头选项Cache-control: no-cache
。您可以使用cURL:执行以下操作
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Cache-control: no-cache");
curl_easy_setopt(mCurl, CURLOPT_HTTPHEADER, headers);
如果您在同一程序中重复使用连接,您可能还想启用:
curl_easy_setopt(mCurl, CURLOPT_FRESH_CONNECT, true);
curl_easy_setopt(mCurl, CURLOPT_FORBID_REUSE , true);
相关文章:
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 导入库可以跨dll版本工作吗
- 在调用FreeLibrary后,释放动态链接到具有相同版本的CRT堆的DLL的内存
- 在clang++预处理器中确定gcc工具链版本
- 码头化的C++应用程序是否向后兼容早期的内核版本
- 不同的Visual Studio版本中缺少.dll
- 用符号版本替换对函数的所有调用
- luaL_dofile在已知良好的字节码上失败,可以使用未编译的版本
- 正在解码MSVC 32位版本的程序集(作业).没有手术做什么
- 我需要分发哪些版本的可再分发文件
- CV_OCL_RUN宏如何在OpenCV(版本3.4.5)的goodFeaturesToTrack实现中工作?
- 在运行时读取 libstdc++ 版本
- 如何声明一个可以在整个程序中使用的全局 2d 3d 4d .. 数组(堆版本)变量?
- FindPackageHandleStandardArgs.cmake:137 的 CMake 错误(消息):找不到 Boost (缺少:正则表达式)(找到合适的版本"1.72.0",
- Vulkan SDK 版本 1.1.85.0 在 Kubuntu 18.10 上链接
- 如何正确实现与基类不同的版本?
- 使 \page 和 \subpage 参考 doxygen 中的方法文档
- 从预处理器获取 Windows 版本(C++ Win32)
- 表达式 SFINAE:如何根据类型是否包含具有一个或多个参数的函数来选择模板版本
- curl检索旧版本的page