Subreddit CSS: Dump permacache-based last modified system.

This system is only used when stylesheets are not hosted on S3. The new
system saves a completely unnecessary C* lookup and ditches one more
thing from the permacache.
This commit is contained in:
Neil Williams
2012-11-26 15:02:56 -08:00
parent 9188eb5c2d
commit 2dea71ad1c
2 changed files with 14 additions and 1 deletions

View File

@@ -401,6 +401,15 @@ class FrontController(RedditController, OAuth2ResourceController):
if stylesheet_contents:
c.allow_loggedin_cache = True
if c.site.stylesheet_modified:
self.abort_if_not_modified(
c.site.stylesheet_modified,
private=False,
max_age=timedelta(days=7),
must_revalidate=False,
)
c.response_content_type = 'text/css'
c.response.content = stylesheet_contents
if c.site.type == 'private':

View File

@@ -23,6 +23,7 @@
from __future__ import with_statement
import base64
import datetime
import hashlib
from pylons import c, g
@@ -64,6 +65,7 @@ class Subreddit(Thing, Printable):
stylesheet_rtl = None,
stylesheet_contents = '',
stylesheet_hash = '',
stylesheet_modified = None,
firsttext = strings.firsttext,
header = None,
header_size = None,
@@ -386,13 +388,15 @@ class Subreddit(Thing, Printable):
)
self.stylesheet_contents = ""
self.stylesheet_modified = None
else:
self.stylesheet_hash = hashlib.md5(minified).hexdigest()
self.stylesheet_contents = minified
set_last_modified(self, 'stylesheet_contents')
self.stylesheet_modified = datetime.datetime.now(g.tz)
else:
self.stylesheet_contents = ""
self.stylesheet_hash = ""
self.stylesheet_modified = datetime.datetime.now(g.tz)
self.stylesheet_contents_user = "" # reads from wiki; ensure pg clean
self._commit()