Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Noah Brackenbury
erp5
Commits
37d2a231
Commit
37d2a231
authored
Jan 14, 2014
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement RFC 5861 into HTTP Accelerated Cache
parent
5134943e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
181 additions
and
0 deletions
+181
-0
product/ERP5Type/ZopePatch.py
product/ERP5Type/ZopePatch.py
+1
-0
product/ERP5Type/dtml/propsAccel.dtml
product/ERP5Type/dtml/propsAccel.dtml
+87
-0
product/ERP5Type/patches/AcceleratedHTTPCacheManager.py
product/ERP5Type/patches/AcceleratedHTTPCacheManager.py
+93
-0
No files found.
product/ERP5Type/ZopePatch.py
View file @
37d2a231
...
...
@@ -77,6 +77,7 @@ from Products.ERP5Type.patches import default_zpublisher_encoding
from
Products.ERP5Type.patches
import
DCWorkflowGraph
from
Products.ERP5Type.patches
import
AceEditorZMI
from
Products.ERP5Type.patches
import
CachingPolicyManager
from
Products.ERP5Type.patches
import
AcceleratedHTTPCacheManager
# These symbols are required for backward compatibility
from
Products.ERP5Type.patches.PropertyManager
import
ERP5PropertyManager
...
...
product/ERP5Type/dtml/propsAccel.dtml
0 → 100644
View file @
37d2a231
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<form action="manage_editProps" method="POST">
<dtml-with getSettings mapping>
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top">
<div class="form-optional">
Title
</div>
</td>
<td align="left" valign="top">
<input type="text" name="title" size="40"
value="&dtml-title;" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Interval (seconds)
</div>
</td>
<td align="left" valign="top">
<input type="text" name="interval" size="40"
value="&dtml-interval;" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Stale if Error Interval (seconds)
</div>
</td>
<td align="left" valign="top">
<input type="text" name="stale_if_error_interval" size="40"
value="&dtml-stale_if_error_interval;" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Stale While Revalidate Interval (seconds)
</div>
</td>
<td align="left" valign="top">
<input type="text" name="stale_while_revalidate_interval" size="40"
value="&dtml-stale_while_revalidate_interval;" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Cache anonymous <br />connections only?
</div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="anonymous_only" value="1"<dtml-if
anonymous_only> checked="checked"</dtml-if> />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Notify URLs (via PURGE)
</div>
</td>
<td align="left" valign="top">
<textarea name="notify_urls:lines" rows="5" cols="30"><dtml-in
notify_urls>&dtml-sequence-item;</dtml-in></textarea>
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="submit"
value="Save Changes" />
</div>
</td>
</tr>
</table>
</dtml-with>
</form>
<dtml-var manage_page_footer>
product/ERP5Type/patches/AcceleratedHTTPCacheManager.py
0 → 100644
View file @
37d2a231
import
time
from
Products.StandardCacheManagers.AcceleratedHTTPCacheManager
import
\
AcceleratedHTTPCache
,
AcceleratedHTTPCacheManager
from
App.Common
import
rfc1123_date
from
App.special_dtml
import
DTMLFile
from
Products.ERP5Type
import
_dtmldir
def
ZCache_set
(
self
,
ob
,
data
,
view_name
,
keywords
,
mtime_func
):
# Note the blatant ignorance of view_name and keywords.
# Standard HTTP accelerators are not able to make use of this
# data. mtime_func is also ignored because using "now" for
# Last-Modified is as good as using any time in the past.
REQUEST
=
ob
.
REQUEST
RESPONSE
=
REQUEST
.
RESPONSE
anon
=
1
u
=
REQUEST
.
get
(
'AUTHENTICATED_USER'
,
None
)
if
u
is
not
None
:
if
u
.
getUserName
()
!=
'Anonymous User'
:
anon
=
0
phys_path
=
ob
.
getPhysicalPath
()
if
phys_path
in
self
.
hit_counts
:
hits
=
self
.
hit_counts
[
phys_path
]
else
:
self
.
hit_counts
[
phys_path
]
=
hits
=
[
0
,
0
]
if
anon
:
hits
[
0
]
=
hits
[
0
]
+
1
else
:
hits
[
1
]
=
hits
[
1
]
+
1
if
not
anon
and
self
.
anonymous_only
:
return
# Set HTTP Expires and Cache-Control headers
seconds
=
self
.
interval
cache_control_parameter
=
[
'max-age=%d'
%
(
seconds
,)]
expires
=
rfc1123_date
(
time
.
time
()
+
seconds
)
if
getattr
(
self
,
'stale_if_error_interval'
,
0
):
cache_control_parameter
.
append
(
"stale-if-error=%d"
\
%
(
self
.
stale_if_error_interval
))
if
getattr
(
self
,
'stale_while_revalidate_interval'
,
0
):
cache_control_parameter
.
append
(
"stale-while-revalidate=%d"
\
%
(
self
.
stale_while_revalida_interval
))
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
time
.
time
()))
RESPONSE
.
setHeader
(
'Cache-Control'
,
", "
.
join
(
cache_control_parameter
))
RESPONSE
.
setHeader
(
'Expires'
,
expires
)
AcceleratedHTTPCache
.
ZCache_set
=
ZCache_set
def
__init__
(
self
,
ob_id
):
self
.
id
=
ob_id
self
.
title
=
''
self
.
_settings
=
{
'anonymous_only'
:
1
,
'interval'
:
3600
,
'stale_if_error_interval'
:
300
,
'stale_while_revalidate'
:
10
,
'notify_urls'
:
()}
self
.
_resetCacheId
()
def
manage_editProps
(
self
,
title
,
settings
=
None
,
REQUEST
=
None
):
' '
if
settings
is
None
:
settings
=
REQUEST
self
.
title
=
str
(
title
)
self
.
_settings
=
{
'anonymous_only'
:
settings
.
get
(
'anonymous_only'
)
and
1
or
0
,
'interval'
:
int
(
settings
[
'interval'
]),
'stale_if_error_interval'
:
int
(
settings
[
'stale_if_error_interval'
]),
'stale_while_revalidate_interval'
:
int
(
settings
[
'stale_while_revalidate_interval'
]),
'notify_urls'
:
tuple
(
settings
[
'notify_urls'
])}
cache
=
self
.
ZCacheManager_getCache
()
cache
.
initSettings
(
self
.
_settings
)
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
,
manage_tabs_message
=
'Properties changed.'
)
def
getSettings
(
self
):
' '
if
'stale_if_error_interval'
not
in
self
.
_settings
:
self
.
_settings
.
update
({
'stale_if_error_interval'
:
0
})
if
'stale_while_revalidate_interval'
not
in
self
.
_settings
:
self
.
_settings
.
update
({
'stale_while_revalidate_interval'
:
0
})
return
self
.
_settings
.
copy
()
# Don't let UI modify it.
AcceleratedHTTPCacheManager
.
__init__
=
__init__
AcceleratedHTTPCacheManager
.
getSettings
=
getSettings
AcceleratedHTTPCacheManager
.
manage_editProps
=
manage_editProps
AcceleratedHTTPCacheManager
.
manage_main
=
DTMLFile
(
"propsAccel"
,
_dtmldir
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment