staticfilecache icon indicating copy to clipboard operation
staticfilecache copied to clipboard

http headers not respected by nginx

Open Micha-sus opened this issue 2 years ago • 2 comments

Bug Report

Current Behavior A static file is correctly generated by staticfilecache on first hit. After that, Nginx serves the generated "index" file from the temp folder, but with the default http headers. Content-Type, Cache-Control, Expires headers etc. are not respected by NginX. So all cached files are served indefinitely, the application is never hit to regenerate the static file.

Expected behavior/output After the statically cached file expires, TYPO3 is executed and the cached file is replaced with a current version.

I don't have much experience with NginX and its configuration, so I don't know whether the server is misconfigured, this is a bug or this is not possible at all with Nginx.

Environment

  • TYPO3 version: 9.5.31
  • staticfilecache version: 11.1.7
  • Composer Mode: yes
  • OS: Ubuntu 20.04
  • NginX: 1.21
  • PHP: 7.4.29
  • TYPO3 Version: 9.5.31
  • SFC Version: 11.1.7
  • PHP Version: 7.4.29
  • OS: Unix
  • Composer: yes
  • SFC Settings: (see below)
  • backendDisplayMode: both
  • boostMode: 0
  • cacheTagsEnable: 1
  • clearCacheForAllDomains: 1
  • debugHeaders: 1
  • disableInDevelopment: 0
  • enableGeneratorBrotli: 0
  • enableGeneratorGzip: 0
  • enableGeneratorManifest: 0
  • enableGeneratorPlain: 1
  • hashUriInCache: 0
  • htaccessTemplateName: EXT:staticfilecache/Resources/Private/Templates/Htaccess.html
  • overrideCacheDirectory:
  • rawurldecodeCacheFileName: 0
  • renameTablesToOtherPrefix: 1
  • sendCacheControlHeaderRedirectAfterCacheTimeout: 1
  • sendHttp2PushEnable: 0
  • sendHttp2PushFileExtensions: css,js,jpg,jpeg,png
  • sendHttp2PushFileLimit: 50
  • useFallbackMiddleware: 1
  • useReverseUriLengthInPriority: 1
  • validHtaccessHeaders: Content-Type,Content-Language,Link,X-SFC-Tags

NginX Config for TYPO3 and StaticFileCache (Timme Hosting) nginx.txt

Micha-sus avatar May 11 '22 13:05 Micha-sus

Hey @Micha-sus thanks for reporting. Do you have a good solution for this problem. There is this ConfigGenerator https://github.com/lochmueller/staticfilecache/blob/master/Classes/Generator/ConfigGenerator.php that create a JSON with all the information of the cache. But how we could pipe this into NGINX? Or should we create a other NGINX related file in this folder (other format?) Regards, Tim

lochmueller avatar May 11 '22 13:05 lochmueller

Hi @lochmueller I can't think of any solution for this. I don't know how to make NginX read an expiration date and redirect to index.php if it is reached. As far as I know, NginX can only be configured with a vHost config, which has performance benefits, because it doesn't read a file based configuration like .htaccess on every request. But as I mentioned before, I'm no expert. That's why I opened this issue :-)

Kind regards, Micha

Micha-sus avatar May 11 '22 14:05 Micha-sus