BKWLD / freezer

Using Laravel, creates cached versions of full pages that can be served directly by Apache
MIT License
9 stars 2 forks source link

Add enable() / disable() API #21

Open weotch opened 10 years ago

weotch commented 10 years ago

Inspired by the conversation in #20. The idea is that you could register a callback function that would be used to determine whether to cache the current request.

weotch commented 10 years ago

To tell Apache to NOT use the cache, the freezer-skip cookie needs to be present. The freezer-skip cookie would need to be added when the user logs in. Maybe with an API like:

Freezer::disable()

The current conditionallyCache() would delete the freezer-skip on the next request though. I think maybe we save a session variable like freezer_disable => true. This is set when Freezer::disable() is called. conditionallyCache() does not delete the freezer-skip if that variable is present. When the user logs out again, the dev calls:

Freezer::enable()

That would clear the freezer_disable session var, restoring Freezer to it's normal behavior.

Thus, we don't need a callback registration thing. Updating the ticket title.

weotch commented 10 years ago

To summarize the changes:

Freezer::disable()

Freezer::enable()

weotch commented 10 years ago

@sdaves, you think this would solve for your use case?

sdaves commented 10 years ago

It just may! Can you commit the changes to a branch so I can test it?

Robert Reinhard notifications@github.com wrote:

@sdaves, you think this would solve for your use case?


Reply to this email directly or view it on GitHub: https://github.com/BKWLD/freezer/issues/21#issuecomment-32197072

weotch commented 10 years ago

Ok, try the above commit out, found in the toggle-api branch.

sdaves commented 10 years ago

Works perfectly :)

weotch commented 10 years ago

Nice, I'll merge it into master.