mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-23 22:08:11 -05:00
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:
@@ -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':
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user