Repository: apache/airflow

Issue:
webserver static file caching is disabled above 2.3.0 version.
### Apache Airflow version

Other Airflow 2 version (please specify below)

### If "Other Airflow 2 version" selected, which one?

2.3.x ~ 2.9.x

### What happened?

Recently, I migrated airflow version 2.2.0 to 2.9.0 and python 3.8 to 3.12.

and i experienced too much load time in airflow web dashboard.
in airflow 2.2.0, airflow dashboard loaded almost instantly. but in 2.9.0, it tooks almost 10 seconds.

## Airflow 2.2.0
<img width="960" alt="image" src="https://github.com/apache/airflow/assets/37045096/1d648049-424c-44a1-a505-24fe213f43a7">

## Airflow 2.9.0
<img width="960" alt="image" src="https://github.com/apache/airflow/assets/37045096/ecb58aca-93e9-483f-8e14-d0dc3ce3df6f">



### What you think should happen instead?

I think there is no reason to make slow page loading time because of not using static file caching.

And I figured out the root cause. the problem is airflow webserver's caching is disabled because of bumping up Flask version 1.x to 2.x.

In Flask, there is Configuration Option for static file's Expire time for cache-control.
it is `SEND_FILE_MAX_AGE_DEFAULT`.

In Flask 1.1.x, the default value of `SEND_FILE_MAX_AGE_DEFAULT` is 12 hours.
https://flask.palletsprojects.com/en/1.1.x/api/#flask.Flask.send_file_max_age_default
![image](https://github.com/apache/airflow/assets/37045096/145d6241-ee75-4210-9355-b57c379cbcd8)

After Flask 2.0.x, the default value of `SEND_FILE_MAX_AGE_DEFAULT` is changed to None.
https://flask.palletsprojects.com/en/2.0.x/api/#flask.Flask.send_file_max_age_default
![image](https://github.com/apache/airflow/assets/37045096/e95ed8a3-2cab-47f8-8de4-99a8beb9e8c5)

after Airflow 2.3.0, Flask version is upgraded to 2.0.x.

When i added flask configuration in app.py
static file caching works well.
![image](https://github.com/apache/airflow/assets/37045096/1b3a02a4-8d7a-4ba9-9e2c-cea3857a0a8e)
![290_with_caching](https://github.com/apache/airflow/assets/37045096/be05516e-31e4-4c2d-bf79-173ad28e0d58)
example is here. https://github.com/VertexToEdge/airflow-docker-compose



### How to reproduce

I followed setup instruction in https://airflow.apache.org/docs/apache-airflow/stable/howto/docker-compose/index.html
1. Setup Airflow 2.9.0 with docker-compose
``` bash
curl -LfO 'https://airflow.apache.org/docs/apache-airflow/2.9.0/docker-compose.yaml'
AIRFLOW_UID=$(id -u) docker compose up
```

2. access airflow webserver with webbrowser. and refresh the page.



### Operating System

Ubuntu 22.04.3 LTS

### Versions of Apache Airflow Providers

_No response_

### Deployment

Docker-Compose

### Deployment details

_No response_

### Anything else?

I am newbie in Airflow.
I read airflow installation guide and configruation reference. but I'm not sure if there is a better way to do this without changing the code.
Is there any way to configure static file caching? please just talk to me.

thanks for reading. have a good day.

### Are you willing to submit PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)



Discussion:
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.


Resolving patch:
diff --git a/airflow/www/app.py b/airflow/www/app.py
--- a/airflow/www/app.py
+++ b/airflow/www/app.py
@@ -121,6 +121,10 @@ def create_app(config=None, testing=False):
         cookie_samesite_config = "Lax"
     flask_app.config["SESSION_COOKIE_SAMESITE"] = cookie_samesite_config
 
+    # Above Flask 2.0.x, default value of SEND_FILE_MAX_AGE_DEFAULT changed 12 hours to None.
+    # for static file caching, it needs to set value explicitly.
+    flask_app.config["SEND_FILE_MAX_AGE_DEFAULT"] = timedelta(seconds=43200)
+
     if config:
         flask_app.config.from_mapping(config)
 


Test patch: