estrattonbailey / operator

1.8kb drop-in "PJAX" solution for fluid, smooth transitions between pages.
90 stars 11 forks source link

Omit certain pages from cache #10

Closed JPrisk closed 6 years ago

JPrisk commented 6 years ago

@estrattonbailey, i've been enjoying testing out operator. Was just wondering if it is possible to omit pages from the cache, for example a cart page?

estrattonbailey commented 6 years ago

Hey @JPrisk! That's a really great idea, I should have considered that up front.

Do you have any ideas on what the API should be like? I imagine it could be as simple as passing an object instead of an array as a route i.e.:

operator('#root', [
  { path: '/cart', cache: false, load () {} }
])
JPrisk commented 6 years ago

@estrattonbailey yea, the suggestion you've made would work well. I guess it would require a rewrite to implement as the current processes rely on a key/ value paring? I'm going to convert the cart page to make an AJAX request on load.

estrattonbailey commented 6 years ago

Yeah, should be pretty simple to make objects optional. Would be happy to review a PR if you wanted to have a look at it. I might get to it this weekend also.

estrattonbailey commented 6 years ago

@JPrisk have a look at the new API. Published as a minor version, you'll just need to run npm i operator@latest --save.

Will this work for you?

JPrisk commented 6 years ago

@estrattonbailey awesome Eric! I'll drop it into my project tomorrow. Ignoring routes is a good idea too