danwent / Perspectives-Server

network notary implementation for the Perspectives project
http://perspectives-project.org
GNU General Public License v3.0
50 stars 13 forks source link

Fix issue 42 - Add HTTP Cache-Control headers #60

Open netsafe opened 9 years ago

netsafe commented 9 years ago

Fixing issue #42 added the header : Cache-Control: private, max-age=3600

daveschaefer commented 9 years ago

Thanks Alexey, I think this would be good. I'd like to test that clients using the Force Notary Check option always get the most recent results; we might need to add an "ignore cache" option in that case.

Thanks for putting your code in separate branches :) It looks like several changelists are duplicated in each branch. That's fine; I'll likely just cherrypick them out rather than merging this entirely through the github interface.

daveschaefer commented 9 years ago

We may also want to consider adding a Last-Modified header

netsafe commented 9 years ago

Last-Modified is good, but in conjunction with Expires only... The problem is, that inside a notary code you can not know when the next scanner run will be performed : it can be launched in a separate server by the way, if they're using the same SQL database and memcached instances. So Last-Modified will add clearance for sure, but will not save the day alone. Using nginx with memcached support will do what you want : I've implemented a cache deletions in a threaded_scanner.py so the data in memcached will be invalidated for both notary and nginx - it will be just destroyed by key. And neither nginx cache, nor nginx-memcached will find a stale answer, and - notary uses the same memcached and it will find no stale data either, so it will be forced to re-query the DB backend to pull out a fresh valid information. That how it works