Title: [256453] trunk/Tools
- Revision
- 256453
- Author
- [email protected]
- Date
- 2020-02-12 10:47:58 -0800 (Wed, 12 Feb 2020)
Log Message
results.webkit.org: Cache archive content
https://bugs.webkit.org/show_bug.cgi?id=207589
Reviewed by Aakash Jain.
* resultsdbpy/resultsdbpy/flask_support/util.py:
(cache_for): Add decorator function which sets the cache values on the returned response.
* resultsdbpy/resultsdbpy/view/archive_view.py:
(ArchiveView): Cache archive content client-side for 12 hours.
* resultsdbpy/resultsdbpy/view/archive_view_unittest.py:
(ArchiveViewUnittest.test_file): Verify that archived content is cached.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (256452 => 256453)
--- trunk/Tools/ChangeLog 2020-02-12 18:46:31 UTC (rev 256452)
+++ trunk/Tools/ChangeLog 2020-02-12 18:47:58 UTC (rev 256453)
@@ -1,3 +1,17 @@
+2020-02-12 Jonathan Bedard <[email protected]>
+
+ results.webkit.org: Cache archive content
+ https://bugs.webkit.org/show_bug.cgi?id=207589
+
+ Reviewed by Aakash Jain.
+
+ * resultsdbpy/resultsdbpy/flask_support/util.py:
+ (cache_for): Add decorator function which sets the cache values on the returned response.
+ * resultsdbpy/resultsdbpy/view/archive_view.py:
+ (ArchiveView): Cache archive content client-side for 12 hours.
+ * resultsdbpy/resultsdbpy/view/archive_view_unittest.py:
+ (ArchiveViewUnittest.test_file): Verify that archived content is cached.
+
2020-02-12 Youenn Fablet <[email protected]>
WebSWServerConnection::registerServiceWorkerClient is not sending IPC message to UIProcess when it should
Modified: trunk/Tools/resultsdbpy/resultsdbpy/flask_support/util.py (256452 => 256453)
--- trunk/Tools/resultsdbpy/resultsdbpy/flask_support/util.py 2020-02-12 18:46:31 UTC (rev 256452)
+++ trunk/Tools/resultsdbpy/resultsdbpy/flask_support/util.py 2020-02-12 18:47:58 UTC (rev 256453)
@@ -114,3 +114,18 @@
real_method.__name__ = method.__name__
return real_method
return decorator
+
+
+def cache_for(hours=12):
+ def decorator(method):
+ def real_method(self=None, method=method, **kwargs):
+ if self:
+ response = method(self=self, **kwargs)
+ else:
+ response = method(**kwargs)
+ response.headers.add('Cache-Control', f'public,max-age={hours * 60 * 60}')
+ return response
+
+ real_method.__name__ = method.__name__
+ return real_method
+ return decorator
Modified: trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view.py (256452 => 256453)
--- trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view.py 2020-02-12 18:46:31 UTC (rev 256452)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view.py 2020-02-12 18:47:58 UTC (rev 256453)
@@ -26,7 +26,7 @@
from resultsdbpy.controller.commit_controller import uuid_range_for_query, HasCommitContext
from resultsdbpy.controller.configuration_controller import configuration_for_query
from resultsdbpy.controller.suite_controller import time_range_for_query
-from resultsdbpy.flask_support.util import AssertRequest, query_as_kwargs, limit_for_query, boolean_query, query_as_string
+from resultsdbpy.flask_support.util import AssertRequest, boolean_query, cache_for, limit_for_query, query_as_kwargs, query_as_string
from resultsdbpy.view.site_menu import SiteMenu
@@ -62,6 +62,7 @@
@limit_for_query(DEFAULT_LIMIT)
@configuration_for_query()
@time_range_for_query()
+ @cache_for(hours=12)
def extract(
self, path=None, format=None,
suite=None, configurations=None, recent=None,
Modified: trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view_unittest.py (256452 => 256453)
--- trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view_unittest.py 2020-02-12 18:46:31 UTC (rev 256452)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view_unittest.py 2020-02-12 18:47:58 UTC (rev 256453)
@@ -73,3 +73,4 @@
response = client.get(self.URL + '/archive/file.txt')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.text, 'data')
+ self.assertEqual(response.headers.get('Cache-Control'), 'public,max-age=43200')
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes