Changeset 256453 in webkit


Ignore:
Timestamp:
Feb 12, 2020 10:47:58 AM (4 years ago)
Author:
Jonathan Bedard
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.

Location:
trunk/Tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r256432 r256453  
     12020-02-12  Jonathan Bedard  <jbedard@apple.com>
     2
     3        results.webkit.org: Cache archive content
     4        https://bugs.webkit.org/show_bug.cgi?id=207589
     5
     6        Reviewed by Aakash Jain.
     7
     8        * resultsdbpy/resultsdbpy/flask_support/util.py:
     9        (cache_for): Add decorator function which sets the cache values on the returned response.
     10        * resultsdbpy/resultsdbpy/view/archive_view.py:
     11        (ArchiveView): Cache archive content client-side for 12 hours.
     12        * resultsdbpy/resultsdbpy/view/archive_view_unittest.py:
     13        (ArchiveViewUnittest.test_file): Verify that archived content is cached.
     14
    1152020-02-12  Youenn Fablet  <youenn@apple.com>
    216
  • trunk/Tools/resultsdbpy/resultsdbpy/flask_support/util.py

    r253721 r256453  
    115115        return real_method
    116116    return decorator
     117
     118
     119def cache_for(hours=12):
     120    def decorator(method):
     121        def real_method(self=None, method=method, **kwargs):
     122            if self:
     123                response = method(self=self, **kwargs)
     124            else:
     125                response = method(**kwargs)
     126            response.headers.add('Cache-Control', f'public,max-age={hours * 60 * 60}')
     127            return response
     128
     129        real_method.__name__ = method.__name__
     130        return real_method
     131    return decorator
  • trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view.py

    r253721 r256453  
    2727from resultsdbpy.controller.configuration_controller import configuration_for_query
    2828from resultsdbpy.controller.suite_controller import time_range_for_query
    29 from resultsdbpy.flask_support.util import AssertRequest, query_as_kwargs, limit_for_query, boolean_query, query_as_string
     29from resultsdbpy.flask_support.util import AssertRequest, boolean_query, cache_for, limit_for_query, query_as_kwargs, query_as_string
    3030from resultsdbpy.view.site_menu import SiteMenu
    3131
     
    6363    @configuration_for_query()
    6464    @time_range_for_query()
     65    @cache_for(hours=12)
    6566    def extract(
    6667        self, path=None, format=None,
  • trunk/Tools/resultsdbpy/resultsdbpy/view/archive_view_unittest.py

    r253721 r256453  
    7474        self.assertEqual(response.status_code, 200)
    7575        self.assertEqual(response.text, 'data')
     76        self.assertEqual(response.headers.get('Cache-Control'), 'public,max-age=43200')
Note: See TracChangeset for help on using the changeset viewer.