Skip to content

Commit d0baadf

Browse files
authored
feat: nginx: cache responses from app/download.php results (#44)
* feat: nginx: cache responses from app/download.php results This configuration change prevents the browser from systematically downloading thumbnails of uploaded files. Because "uploads" URLs are always pointing to the same exact file, we can cache the response.
1 parent 1cf7d20 commit d0baadf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/nginx/common.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ location = /nginx-status {
7878
# deny access to hidden files/folders
7979
location ~ /\. { access_log off; log_not_found off; deny all; }
8080

81+
# for user uploaded files, use a long cache value, as uploads are not modified anyway: an URL points always to the same exact file
82+
location ^~ /app/download.php {
83+
more_set_headers "Cache-Control: public, max-age=31536000";
84+
include /etc/nginx/fastcgi.conf;
85+
fastcgi_index index.php;
86+
log_not_found off;
87+
88+
if (-f $request_filename) {
89+
fastcgi_pass unix:/run/php-fpm.sock;
90+
}
91+
}
92+
8193
# assets configuration
8294
location ~* \.(js|css|png|jpg|jpeg|gif|ico|map|ttf|txt|woff|woff2|svg|webmanifest)$ {
8395
access_log off;

0 commit comments

Comments
 (0)