Http 1.1 Caching support

Please post support and help requests here.
Posts: 17
Joined: 11 Mar 2013, 16:10

Http 1.1 Caching support

Postby devdavid » 12 Apr 2013, 06:44

Hi, I wonder whetter the support for http 1.1 response caching is included in POCO/Net.

I would like to use some conditional caching, ie. if a file on the server is updated, my client's poco http request should get the new version, otherwise it should fetch it from disk cache. Below is my code for fetching data, does something need to be added to enable persistent caching?

Best Regards David

Code: Select all

int NetPoco::getJson(string url){

      printnet("Prepare session");

       // prepare session
       URI uri("");
       HTTPClientSession session(uri.getHost(), uri.getPort());

       // prepare path
      printnet("Prepare path");

       string path(uri.getPathAndQuery());
       if (path.empty()) path = "/";

       // send request
      printnet("Prepare request for");
       HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);

       // get response
      printnet("Get response");

       HTTPResponse res;
       cout << res.getStatus() << " " << res.getReason() << endl;

       // print response
      printnet("Print response");

       istream &is = session.receiveResponse(res);
       //StreamCopier::copyStream(is, cout);
       std::stringstream ss;

     catch (Exception &ex)
       return -1;

     return 0;

So part of the answer is here:

To move on and make an own strategy for this caching i think i need to get expires from the cache headers and cross check with cached values (please tell me if im wrong). So how can i extract the cache header from httpResponse?

Best regards!

Return to “Support”

Who is online

Users browsing this forum: No registered users and 3 guests