lochmueller/staticfilecache

Ho to get rid of "Header set X-SFC-Tags" in generated htaccess files?

claude27 opened this issue · 5 comments

Hi,

is there a possibility to get rid of the "Header set X-SFC-Tags" in the generated htaccess files?
On a page with many content elements and many images the string X-SFC-Tags is too long for the htacess file. As result an "Internal Server Error" is shown for the cached page. See an example below.

The extensions settings "Debug headers" and "Enable Cache Tags" are not set.

I think the problem is that in the file PrepareMiddleware.php, line 71
$cacheTags[] = 'explanation';
always sets an cacheTag, so the cacheTags array is never null.

Environment

  • TYPO3 version: 10.4.31
  • staticfilecache version: 12.4.5
  • Is your TYPO3 installation set up with Composer (Composer Mode): yes
  • OS: Linux (DomainFactory), Apache

Additional context
Broken htaccess File:

ForceType text/html


<IfModule mod_rewrite.c>
	RewriteEngine On
	
	RewriteCond %{ENV:REDIRECT_STATUS} ^$
	RewriteRule .* - [F,L]

	RewriteCond %{TIME} >20220728003257
	RewriteRule ^.*$ /index.php
</IfModule>



	<IfModule mod_headers.c>
		
				Header set Content-Type "text/html; charset=utf-8"
		
				Header set Content-Language "de"
		
				Header set X-SFC-Tags "pages_7168, pages_6566, pages_6578, sys_file_processedfile_355383, sys_file_50233, sys_file_metadata_48478, tt_content_46682, sys_file_processedfile_479053, sys_file_85382, sys_file_metadata_85236, sys_file_processedfile_479054, sys_file_processedfile_479055, sys_file_85380, sys_file_metadata_85234, sys_file_processedfile_479056, sys_file_processedfile_479057, sys_file_85381, sys_file_metadata_85235, sys_file_processedfile_479058, sys_file_processedfile_479059, sys_file_85379, sys_file_metadata_85233, sys_file_processedfile_479060, tt_content_46562, sys_file_processedfile_478162, sys_file_84284, sys_file_metadata_84138, sys_file_processedfile_478163, sys_file_85228, sys_file_metadata_85082, sys_file_processedfile_478137, sys_file_processedfile_478164, sys_file_85226, sys_file_metadata_85080, sys_file_processedfile_478139, sys_file_processedfile_478165, sys_file_85230, sys_file_metadata_85084, sys_file_processedfile_478143, sys_file_processedfile_478166, sys_file_85223, sys_file_metadata_85077, sys_file_processedfile_478145, sys_file_processedfile_478167, sys_file_85229, sys_file_metadata_85083, sys_file_processedfile_478149, sys_file_processedfile_478169, sys_file_85231, sys_file_metadata_85085, sys_file_processedfile_478153, sys_file_processedfile_478170, sys_file_85224, sys_file_metadata_85078, sys_file_processedfile_478155, sys_file_processedfile_478168, sys_file_85227, sys_file_metadata_85081, sys_file_processedfile_478171, sys_file_85222, sys_file_metadata_85076, sys_file_processedfile_478157, sys_file_processedfile_478172, sys_file_85234, sys_file_metadata_85088, sys_file_processedfile_478159, tt_content_45635, sys_file_processedfile_473180, sys_file_84283, sys_file_metadata_84137, sys_file_processedfile_474922, sys_file_processedfile_473181, sys_file_84282, sys_file_metadata_84136, sys_file_processedfile_474923, sys_file_processedfile_473182, sys_file_84278, sys_file_metadata_84132, sys_file_processedfile_474924, sys_file_processedfile_473183, sys_file_84279, sys_file_metadata_84133, sys_file_processedfile_474925, sys_file_processedfile_473184, sys_file_84280, sys_file_metadata_84134, sys_file_processedfile_474926, sys_file_processedfile_473185, sys_file_84281, sys_file_metadata_84135, sys_file_processedfile_474927, tt_content_44677, tt_content_43607, sys_file_processedfile_462868, sys_file_82353, sys_file_metadata_82206, sys_file_processedfile_462870, sys_file_82358, sys_file_metadata_82209, sys_file_processedfile_462872, sys_file_82354, sys_file_metadata_82207, sys_file_processedfile_462874, sys_file_82357, sys_file_metadata_82210, sys_file_processedfile_462876, sys_file_82355, sys_file_metadata_82211, sys_file_processedfile_462878, sys_file_82356, sys_file_metadata_82208, tt_content_43399, sys_file_processedfile_461961, sys_file_82120, sys_file_metadata_81973, sys_file_processedfile_461962, sys_file_processedfile_461963, sys_file_82119, sys_file_metadata_81972, sys_file_processedfile_461964, sys_file_processedfile_461965, sys_file_82118, sys_file_metadata_81971, sys_file_processedfile_461966, sys_file_processedfile_461967, sys_file_82117, sys_file_metadata_81970, sys_file_processedfile_461968, sys_file_processedfile_461969, sys_file_82123, sys_file_metadata_81976, sys_file_processedfile_461970, sys_file_processedfile_461971, sys_file_82116, sys_file_metadata_81969, sys_file_processedfile_461972, sys_file_processedfile_461973, sys_file_82122, sys_file_metadata_81975, sys_file_processedfile_461974, sys_file_processedfile_461975, sys_file_82121, sys_file_metadata_81974, sys_file_processedfile_461976, tt_content_42806, sys_file_processedfile_458867, sys_file_81954, sys_file_metadata_81807, sys_file_processedfile_458868, sys_file_81949, sys_file_metadata_81802, sys_file_processedfile_458869, sys_file_81953, sys_file_metadata_81806, sys_file_processedfile_458870, sys_file_81951, sys_file_metadata_81804, sys_file_processedfile_458871, sys_file_81952, sys_file_metadata_81805, sys_file_processedfile_458872, sys_file_81950, sys_file_metadata_81803, tt_content_42301, sys_file_processedfile_455677, sys_file_81190, sys_file_metadata_81042, sys_file_processedfile_455679, sys_file_81418, sys_file_metadata_81270, sys_file_processedfile_455681, sys_file_81420, sys_file_metadata_81272, sys_file_processedfile_455683, sys_file_81419, sys_file_metadata_81271, sys_file_processedfile_455685, sys_file_81421, sys_file_metadata_81273, tt_content_42535, sys_file_processedfile_455693, sys_file_81108, sys_file_metadata_80958, sys_file_processedfile_455697, sys_file_81423, sys_file_metadata_81275, sys_file_processedfile_455667, sys_file_processedfile_455696, sys_file_81424, sys_file_metadata_81276, sys_file_processedfile_455694, sys_file_81422, sys_file_metadata_81274, sys_file_processedfile_455695, sys_file_81425, sys_file_metadata_81277, tt_content_42264, sys_file_processedfile_453771, sys_file_81146, sys_file_metadata_80996, sys_file_processedfile_453773, sys_file_81147, sys_file_metadata_80997, sys_file_processedfile_453775, sys_file_81145, sys_file_metadata_80995, sys_file_processedfile_453777, sys_file_81148, sys_file_metadata_80998, tt_content_41995, sys_file_processedfile_453534, sys_file_80879, sys_file_metadata_80729, sys_file_processedfile_452079, sys_file_processedfile_453535, sys_file_81109, sys_file_metadata_80959, sys_file_processedfile_453537, sys_file_81111, sys_file_metadata_80961, sys_file_processedfile_453538, sys_file_processedfile_453539, sys_file_81110, sys_file_metadata_80960, sys_file_80889, sys_file_metadata_80739, tt_content_41996, sys_file_processedfile_452091, sys_file_80882, sys_file_metadata_80732, sys_file_processedfile_452093, sys_file_80884, sys_file_metadata_80734, sys_file_processedfile_452095, sys_file_80883, sys_file_metadata_80733, sys_file_processedfile_452097, sys_file_80880, sys_file_metadata_80730, sys_file_processedfile_452099, sys_file_80881, sys_file_metadata_80731, sys_file_processedfile_452101, sys_file_80885, sys_file_metadata_80735, tt_content_41697, sys_file_processedfile_449684, sys_file_80574, sys_file_metadata_80424, sys_file_processedfile_449686, sys_file_80575, sys_file_metadata_80425, sys_file_processedfile_449688, sys_file_80573, sys_file_metadata_80423, sys_file_processedfile_449690, sys_file_80570, sys_file_metadata_80420, sys_file_processedfile_449692, sys_file_80572, sys_file_metadata_80422, sys_file_processedfile_449694, sys_file_80571, sys_file_metadata_80421, sys_file_80547, sys_file_metadata_80397, sys_file_80546, sys_file_metadata_80396, tt_content_40617, sys_file_processedfile_446929, sys_file_80070, sys_file_metadata_79918, sys_file_processedfile_446931, sys_file_80073, sys_file_metadata_79921, sys_file_processedfile_446933, sys_file_80069, sys_file_metadata_79917, sys_file_processedfile_446935, sys_file_80074, sys_file_metadata_79922, sys_file_processedfile_446937, sys_file_80072, sys_file_metadata_79920, sys_file_processedfile_446939, sys_file_80071, sys_file_metadata_79919, sys_file_processedfile_446941, sys_file_80077, sys_file_metadata_79925, sys_file_processedfile_446943, sys_file_80076, sys_file_metadata_79924, sys_file_processedfile_446944, sys_file_processedfile_446945, sys_file_80080, sys_file_metadata_79928, sys_file_processedfile_446946, sys_file_processedfile_446947, sys_file_80079, sys_file_metadata_79927, sys_file_processedfile_446948, sys_file_processedfile_446949, sys_file_80078, sys_file_metadata_79926, sys_file_processedfile_446950, tt_content_40066, sys_file_processedfile_444449, sys_file_79849, sys_file_metadata_79697, tt_content_39799, sys_file_processedfile_443051, sys_file_79644, sys_file_metadata_79492, tt_content_39541, sys_file_processedfile_442415, sys_file_79517, sys_file_metadata_79379, sys_file_79518, sys_file_metadata_79380, tt_content_38151, sys_file_processedfile_431632, sys_file_77873, sys_file_metadata_77735, sys_file_processedfile_431633, tt_content_38042, sys_file_processedfile_429781, sys_file_77679, sys_file_metadata_77541, sys_file_processedfile_429782, sys_file_processedfile_429783, sys_file_77682, sys_file_metadata_77544, sys_file_processedfile_429784, sys_file_processedfile_429785, sys_file_77680, sys_file_metadata_77542, sys_file_processedfile_429786, sys_file_processedfile_429787, sys_file_77681, sys_file_metadata_77543, sys_file_processedfile_429788, sys_file_77684, sys_file_metadata_77546, tt_content_33398, sys_file_processedfile_366365, sys_file_72424, sys_file_metadata_72293, sys_file_processedfile_329004, sys_file_processedfile_366366, sys_file_72425, sys_file_metadata_72294, sys_file_processedfile_329006, sys_file_processedfile_366367, sys_file_72426, sys_file_metadata_72295, sys_file_processedfile_329008, sys_file_processedfile_366368, sys_file_72427, sys_file_metadata_72296, sys_file_processedfile_329013, tt_content_33306, sys_file_processedfile_366369, sys_file_72307, sys_file_metadata_72175, sys_file_processedfile_328260, sys_file_processedfile_366370, sys_file_72308, sys_file_metadata_72176, sys_file_processedfile_328262, sys_file_processedfile_366371, sys_file_72309, sys_file_metadata_72177, sys_file_processedfile_328264, sys_file_processedfile_366372, sys_file_72310, sys_file_metadata_72178, sys_file_processedfile_366373, sys_file_72311, sys_file_metadata_72179, sys_file_processedfile_328268, sys_file_processedfile_366374, sys_file_72312, sys_file_metadata_72180, sys_file_processedfile_328270, sys_file_processedfile_366375, sys_file_72313, sys_file_metadata_72181, sys_file_processedfile_328272, sys_file_processedfile_366376, sys_file_72314, sys_file_metadata_72182, sys_file_processedfile_328274, tt_content_33081, sys_file_processedfile_366377, sys_file_71938, sys_file_metadata_71806, tt_content_33182, sys_file_processedfile_366378, sys_file_72093, sys_file_metadata_71961, sys_file_processedfile_366379, sys_file_72102, sys_file_metadata_71970, sys_file_processedfile_366380, sys_file_72094, sys_file_metadata_71962, sys_file_processedfile_326409, sys_file_processedfile_366381, sys_file_72095, sys_file_metadata_71963, sys_file_processedfile_326411, sys_file_processedfile_366382, sys_file_72097, sys_file_metadata_71965, sys_file_processedfile_366383, sys_file_72098, sys_file_metadata_71966, sys_file_processedfile_326415, sys_file_processedfile_366384, sys_file_72100, sys_file_metadata_71968, sys_file_processedfile_326417, sys_file_processedfile_366385, sys_file_72099, sys_file_metadata_71967, sys_file_processedfile_326419, sys_file_processedfile_366386, sys_file_72101, sys_file_metadata_71969, sys_file_processedfile_326421, sys_file_processedfile_366387, sys_file_72096, sys_file_metadata_71964, sys_file_processedfile_366388, sys_file_72103, sys_file_metadata_71971, sys_file_processedfile_326425, sys_file_processedfile_366389, sys_file_72104, sys_file_metadata_71972, sys_file_processedfile_326427, sys_file_processedfile_366390, sys_file_72105, sys_file_metadata_71973, sys_file_processedfile_366391, sys_file_72106, sys_file_metadata_71974, sys_file_processedfile_326431, tt_content_32973, sys_file_processedfile_366392, sys_file_71764, sys_file_metadata_71613, tt_content_32974, sys_file_processedfile_366393, sys_file_71763, sys_file_metadata_71612, sys_file_processedfile_324249, tt_content_26263, sys_file_processedfile_366394, sys_file_60428, sys_file_metadata_60306, sys_file_processedfile_366395, sys_file_68290, sys_file_metadata_68146, tt_content_31212, sys_file_processedfile_366396, sys_file_68177, sys_file_metadata_68033, sys_file_processedfile_366397, sys_file_68178, sys_file_metadata_68034, sys_file_processedfile_299568, sys_file_processedfile_366398, sys_file_68179, sys_file_metadata_68035, sys_file_processedfile_299570, sys_file_processedfile_366399, sys_file_68180, sys_file_metadata_68036, sys_file_processedfile_299572, sys_file_processedfile_366400, sys_file_68181, sys_file_metadata_68037, sys_file_processedfile_299574, sys_file_processedfile_366401, sys_file_68182, sys_file_metadata_68038, sys_file_processedfile_299576, sys_file_processedfile_366402, sys_file_68183, sys_file_metadata_68039, sys_file_processedfile_299578, sys_file_processedfile_366403, sys_file_68184, sys_file_metadata_68040, sys_file_processedfile_299580, tt_content_30598, sys_file_processedfile_366404, sys_file_67303, sys_file_metadata_67160, sys_file_67400, sys_file_metadata_67255, sys_file_67402, sys_file_metadata_67259, sys_file_67399, sys_file_metadata_67257, sys_file_67405, sys_file_metadata_67261, sys_file_67403, sys_file_metadata_67260, sys_file_67401, sys_file_metadata_67256, sys_file_67404, sys_file_metadata_67258, sys_file_67304, sys_file_metadata_67161, tt_content_29522, sys_file_processedfile_366405, sys_file_65990, sys_file_metadata_65846, sys_file_processedfile_366406, sys_file_65991, sys_file_metadata_65847, tt_content_27884, sys_file_processedfile_366407, sys_file_63410, sys_file_metadata_63265, sys_file_processedfile_366408, sys_file_63411, sys_file_metadata_63266, tt_content_23945, sys_file_processedfile_366409, sys_file_57920, sys_file_metadata_57801, tt_content_20163, sys_file_processedfile_366410, sys_file_50654, sys_file_metadata_48892, sys_file_processedfile_366411, sys_file_50653, sys_file_metadata_48891, sys_file_processedfile_366412, sys_file_50651, sys_file_metadata_48889, sys_file_processedfile_366413, sys_file_50649, sys_file_metadata_48887, sys_file_processedfile_366414, sys_file_50652, sys_file_metadata_48890, sys_file_processedfile_366415, sys_file_50650, sys_file_metadata_48888, tt_content_20555, sys_file_processedfile_366416, sys_file_51554, sys_file_metadata_49820, tt_content_21534, tt_content_21535, tt_content_21536, pages_6592, pages_6591, pages_10922, pages_6590, pages_6588, pages_11638, pages_6577, pages_6579, pages_6576, pages_6575, pages_6629, pages_10855, pages_6608, pages_6599, pages_6609, pages_10456, pages_6572, pages_10271, pages_7163, pages_6586, pages_8406, pages_6587, pageId_7168"
		
	</IfModule>

Hey @claude27 ,
do you use thi extension: https://extensions.typo3.org/extension/fluid_page_cache
Or what is the reason for the huge amount of tags? The "explanation" should not be the problem. It is just one tag.
I think the headers are fetched here from the response: https://github.com/lochmueller/staticfilecache/blob/master/Classes/Generator/HtaccessGenerator.php#L31 Perhaps we should check the length in front of the template assignment?
Please keep also in mindm that the X-SFC-Headers are debug headers. Do you try to disable the debug option?
https://github.com/lochmueller/staticfilecache/blob/master/Classes/Middleware/GenerateMiddleware.php#L128
Regards,
Tim

Hey @lochmueller ,

thank you for your fast answer.
No, I don't use the fluid_page_cache Extension.
The reason is that on this page there are 33 standard text&media content elements with round about 150 images.

Debug Headers is disabled – here some screenshots:
grafik

grafik

grafik

I'm really wondering why the X-SFC-Headers are showing up in the htaccess File, especially as I don't have enabled any debug setting.

PS: I have now changed the setting basic.validHtaccessHeaders (string) to Content-Type,Content-Language,Link
so the problem is now solved for me.

I changed it recently to the standard setting because of another error. Unfortunately I currently don't remember what the problem was. I will think about it, I hope I remember.

Hey,

we encountered the same issue when using b13/menues which added all the menu cache tags to the X-SFC-Tags header.
Removing X-SFC-Tags from the valid headers list works.

Does anyone know what the line length limit for htaccess files is? I can't find any documentation on this. With that info we could add linebreaks to the htaccess file.

Hey @jonakieling . Good point. But I think it is not a problem of the file/line length of the htaccess file. I think it is a problem in the max header size of the Webserver (RFC). E.g. https://www.tutorialspoint.com/What-is-the-maximum-size-of-HTTP-header-values
Perhaps the list of cache tags are more than the 8K. We could also check the length of the header values and trim it to the max length value.

Regards,
Tim