public function save($path, $response, $header) {
        if (!(is_array($response) && count($response) > 0)) {
            $this->__debug("no valid response for $path, will not save, invalidating any saved copy");            
            $this->backend->delete($path);
            return false;
        }

        if ($this->cacheTime == 0) {
            return false;
        }

        $this->object['path'] = $path;
        $this->object['response'] = $response;             
 
        // parse response headers
        $all_headers = array();
        $cache_headers = array();
        
        // collect all headers in nicer format
        $headers = explode("\r\n", $header);
        foreach ($headers as $h) {
            $a = explode(':', $h);
            if (count($a) == 2) {
                $all_headers[trim($a[0])] = trim($a[1]);
            }
        }
        
        // get max-age        
        if (array_key_exists('Cache-Control', $all_headers)) {
            preg_match('/max-age=(\d+)/', $all_headers['Cache-Control'], $cache_headers);            
        }

        if (count($cache_headers)) {
            $this->__debug("got cache-control for $path, cache is valid for {$cache_headers[1]} seconds");
            $this->object['cache'] = (int)(time() + $cache_headers[1]);
            
        } else {
            $this->__debug("no cache-control for $path, caching for {$this->cacheTime} seconds");
            $this->object['cache'] = (int)(time() + $this->cacheTime);            
        }

        // get etag
        $etag = array_key_exists('Etag', $all_headers) ? preg_replace('/"/', '', $all_headers['Etag']) : null;
        if (strlen($etag)) {
            $this->__debug("new etag for $path");            
            $this->object['etag'] = $etag;
            
        } else {
            $this->__debug("no etag for $path");
        }

        $this->backend->delete($path);
        $this->backend->put($this->object);
        
        return true;
    }