Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

3D

INTERN

ADOBE

ARDUINO

BITBUCKET

DOCKER

C4D

GIT

HTML

IPHONE

JAVASCRIPT

JTL-SHOP

LARAVEL

MAGENTO2

MYSQL

PHP

PLESK

PROCESSING

PYTHON

SUITECRM

SEO

TRYTON

THUNDERBIRD / ICEDOVE / FossaMail

TYPO3

TYPO3: BACKEND

TYPO3: TYPOSCRIPT

UNIX

VLC

VVVV

WINDOWS

WINDOWS 10

WORDPRESS

XAMPP

XT:C 4 (Veyton)

plesk:send-cache-headers-for-all-static-files-served-by-nginx

plesk (12.5): Send cache headers for all static files served by nginx

be sure to know what you're doing, the steps write a custom Vhosts Template that gets parsed by plesk to generate the Vhost conf file for each Domain, the impact could be devastating ;)

first, copy original default nginxVirtualHost template to custom directory (as in [1], [2])

$ mkdir -p /usr/local/psa/admin/conf/templates/custom/domain/
$ cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/

edit the custom template to your liking

$ vi /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php

search location that has 'nginxStaticExtensions' and add 3 lines to make it look like this:

   location ~ ^/(.*\.(<?php echo $VAR->domain->physicalHosting->proxySettings['nginxStaticExtensions'] ?>))$ {
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control public;
        try_files $uri @fallback;
    }

then let plesk generate new domain configs

$ /usr/local/psa/admin/bin/httpdmng --reconfigure-all

optionally, verify the new conf has your additions

$  cat /var/www/vhosts/sampledomain.tld/conf/nginx.conf | grep 30d
$  curl -I -L -H 'Accept-Encoding: gzip,deflate' https://sampledomain.tld/pathto/a-stati-file.css

you should see 'Expires On' date in the response

from now on, for every filetype described in the plesk panel in the field 'Serve Static files through nginx' will get the cache headers, to tell the browser to keep them.

plesk/send-cache-headers-for-all-static-files-served-by-nginx.txt · Zuletzt geändert: 2016/04/09 06:56 von admin