Permalink
Browse files

De-stale c.site for stylesheet requests.

Since we're using nginx in front of subreddit stylesheets
to protect ourselves from ponies, we need to make sure we
don't give a stale copy of the CSS when requested with the
new query param thereby poisoning nginx's cache.
  • Loading branch information...
1 parent e6555cf commit a0f37adb131e0379b4d1faa8236156765cf58dae @spladug spladug committed May 11, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 r2/r2/controllers/front.py
@@ -358,6 +358,10 @@ def GET_newreddit(self, name):
return res
def GET_stylesheet(self):
+ # de-stale the subreddit object so we don't poison nginx's cache
+ if not isinstance(c.site, FakeSubreddit):
+ c.site = Subreddit._byID(c.site._id, data=True, stale=False)
+
if hasattr(c.site,'stylesheet_contents') and not g.css_killswitch:
c.allow_loggedin_cache = True
self.check_modified(c.site,'stylesheet_contents',

0 comments on commit a0f37ad

Please sign in to comment.