Code Monkey home page Code Monkey logo

Comments (3)

oscarotero avatar oscarotero commented on May 22, 2024

Hello. What are your use case?
This method is used in Middleware::readResponse() and Middleware::saveResponse().
In saveResponse the page is saved only if no query parameters are in the url (https://github.com/oscarotero/psr7-middlewares/blob/master/src/Middleware/SaveResponse.php#L31)
ReadResponse does not check whether there's query parameters in the url. These two middlewares are designed to create a basic file based cache, for static pages, so query parameters are not covered.
Maybe this the problem?

from psr7-middlewares.

Anahkiasen avatar Anahkiasen commented on May 22, 2024

My use case is filtering a timeline, so I have "tabs" of sorts that display different content. I think indeed it's caching the page when there's no query parameter (view all) but then that cache is reused when there are query parameters.

from psr7-middlewares.

oscarotero avatar oscarotero commented on May 22, 2024

To do that, you need to use Cache, combined with any psr6 compliance library. In the tests I'm using http://www.scrapbook.cash/ that have adapters for many storage systems including filesystem (using flysystem). An example:

// create Flysystem object
$adapter = new \League\Flysystem\Adapter\Local('/path/to/cache', LOCK_EX);
$filesystem = new \League\Flysystem\Filesystem($adapter);

// create Scrapbook cache object
$cache = new \MatthiasMullie\Scrapbook\Adapters\Flysystem($filesystem);

// create a psr6 Pool object from cache engine
$pool = new \MatthiasMullie\Scrapbook\Psr6\Pool($cache);

//middlewares
$dispatcher = $relay->newInstance([
    Middleware::cache($pool)
]);

from psr7-middlewares.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.