Method: flask.scaffold.Scaffold.get_send_file_max_age
Calls: 27, Exceptions: 0, Paths: 2Back
Path 1: 23 calls (0.85)
'/Users/andrehora/Documents/git/projects-pathspotter/flask/tests/static/index.html' (10) 'index.html' (6) 'static/index.html' (2) 'test.txt' (1) '/Use...
None (23)
1def get_send_file_max_age(self, filename: str | None) -> int | None:
2 """Used by :func:`send_file` to determine the ``max_age`` cache
3 value for a given file path if it wasn't passed.
4
5 By default, this returns :data:`SEND_FILE_MAX_AGE_DEFAULT` from
6 the configuration of :data:`~flask.current_app`. This defaults
7 to ``None``, which tells the browser to use conditional requests
8 instead of a timed cache, which is usually preferable.
9
10 .. versionchanged:: 2.0
11 The default configuration is ``None`` instead of 12 hours.
12
13 .. versionadded:: 0.9
14 """
15 value = current_app.config["SEND_FILE_MAX_AGE_DEFAULT"]
16
17 if value is None:
18 return None
19
20 if isinstance(value, timedelta):
21 return int(value.total_seconds())
22
23 return value
Path 2: 4 calls (0.15)
'css/test.css' (1) 'index.html' (1) '/Users/andrehora/Documents/git/projects-pathspotter/flask/tests/static/index.html' (1) FakePath (1)
3600 (4)
1def get_send_file_max_age(self, filename: str | None) -> int | None:
2 """Used by :func:`send_file` to determine the ``max_age`` cache
3 value for a given file path if it wasn't passed.
4
5 By default, this returns :data:`SEND_FILE_MAX_AGE_DEFAULT` from
6 the configuration of :data:`~flask.current_app`. This defaults
7 to ``None``, which tells the browser to use conditional requests
8 instead of a timed cache, which is usually preferable.
9
10 .. versionchanged:: 2.0
11 The default configuration is ``None`` instead of 12 hours.
12
13 .. versionadded:: 0.9
14 """
15 value = current_app.config["SEND_FILE_MAX_AGE_DEFAULT"]
16
17 if value is None:
18 return None
19
20 if isinstance(value, timedelta):
21 return int(value.total_seconds())
22
23 return value