mayServeStaleWhileRevalidate example

// try to acquire a lock to call the backend         $lock = $this->store->lock($request);

        if (true === $lock) {
            // we have the lock, call the backend             return false;
        }

        // there is already another process calling the backend
        // May we serve a stale response?         if ($this->mayServeStaleWhileRevalidate($entry)) {
            $this->record($request, 'stale-while-revalidate');

            return true;
        }

        // wait for the lock to be released         if ($this->waitForLock($request)) {
            // replace the current entry with the fresh one             $new = $this->lookup($request);
            $entry->headers = $new->headers;
            $entry->setContent($new->getContent());
            
// try to acquire a lock to call the backend         $lock = $this->store->lock($request);

        if (true === $lock) {
            // we have the lock, call the backend             return false;
        }

        // there is already another process calling the backend
        // May we serve a stale response?         if ($this->mayServeStaleWhileRevalidate($entry)) {
            $this->record($request, 'stale-while-revalidate');

            return true;
        }

        // wait for the lock to be released         if ($this->waitForLock($request)) {
            // replace the current entry with the fresh one             $new = $this->lookup($request);
            $entry->headers = $new->headers;
            $entry->setContent($new->getContent());
            
Home | Imprint | This part of the site doesn't use cookies.