Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Adding http_cache parameter to @viewconfig functions #214

Merged
merged 1 commit into from
Mar 21, 2015

Conversation

rich-hart
Copy link
Contributor

"When you supply an http_cache value to a view configuration, the Expires and Cache-Control headers of a response generated by the associated view callable are modified. The value for http_cache may be ... zero (0). If the value is zero, the Cache-Control and Expires headers present in all responses from this view will be composed such that client browser cache (and any intermediate caches) are instructed to never cache the response."

- pyramid view configuration documentation

All @authenticated_only functions have been set to NO_CACHE

Fixes #206



@view_config(route_name='callback')
@view_config(route_name='callback', http_cache=DEFAULT_CACHE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a mistake here. Don't merge yet.

Now fixed....

@rich-hart rich-hart force-pushed the no_caching_for_authenticated_views branch from 3286e92 to 58c9c90 Compare March 20, 2015 17:42
@@ -106,12 +110,14 @@ def logout(request):
raise httpexceptions.HTTPFound(location=redirect_to)


@view_config(route_name='options', request_method='OPTIONS', renderer='string')
@view_config(route_name='options', request_method='OPTIONS',
renderer='string', http_cache=DEFAULT_CACHE)
def options(request):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to have the @authenticated_only decorator?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this needs to be available at any url and whether you're authenticated or not. Looking at the commit message "Respond to OPTIONS with CORS headers" it was about letting webview use authoring api.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 58c9c90 on no_caching_for_authenticated_views into * on master*.

@rich-hart rich-hart closed this Mar 20, 2015
@rich-hart rich-hart reopened this Mar 20, 2015
@@ -36,6 +36,10 @@
from .storage import storage
from . import utils

NO_CACHE = (0, {'public': True})
TIMED_CACHE = (datetime.timedelta(
weeks=1, days=0, hours=0, minutes=0, seconds=0), {'public': True})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like this is used anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't. I thought that it would be good to keep in a TIMED_CACHE example just in case it proved useful in the future. We can take it out if you think it'll just be distracting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can leave it in - probably want to set some non-zero caching at some point.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 58c9c90 on no_caching_for_authenticated_views into * on master*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 58c9c90 on no_caching_for_authenticated_views into * on master*.

reedstrm added a commit that referenced this pull request Mar 21, 2015
@reedstrm reedstrm merged commit 765ca80 into master Mar 21, 2015
@reedstrm reedstrm deleted the no_caching_for_authenticated_views branch March 21, 2015 21:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect user login
5 participants