No Code Attached Yet bug
avatar elpescador-nl
elpescador-nl
14 Aug 2021

Steps to reproduce the issue

Enable the cache (it does not matter which engine, I tested with redis and file caching). Do not use the Page caching plugin.
The easiest way with an out-of-the-box J!4 installation...
The vcf download of a contact has an extra added header Content-disposition with the card_name in the file name. For example attachment; filename="John Smith.vcf"

Expected result

The Content-disposition: attachment; filename="John Smith.vcf" header is always present. Also when delivering a cached version.

Actual result

The Content-disposition: attachment; filename="John Smith.vcf" header is only present the first time the vcf is loaded. With the cached version this header disappeared.

System information (as much as possible)

  • Joomla! 4.0.0-rc6 Release Candidate
  • php-fpm
  • nginx

Additional comments

As I said this header is just an example. You could also test it by adding this code to a view you want to test:

Factory::getApplication()->setHeader('x-cachetest', 'hello');
avatar elpescador-nl elpescador-nl - open - 14 Aug 2021
avatar joomla-cms-bot joomla-cms-bot - change - 14 Aug 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Aug 2021
avatar elpescador-nl
elpescador-nl - comment - 14 Aug 2021

I already found out the headers are not being stored in the cache at all.

if (isset($options['headers']) && $options['headers'])

When I force this if-clause to be true (change it to if(true)) the header is being stored. I don't think this is the solution, but it might help finding the good solution. I hope this find might help someone with more knowledge of the Caching layer to solve the problem.

In J!3.9 it all works perfectly. I tried to compare the J!4 code with it, but did not get my head around it.

avatar PhilETaylor
PhilETaylor - comment - 18 Aug 2021

Do not use the Page caching plugin.

Isn't this then the correct behaviour? If you are not caching the whole page - with headers - then you cannot expect headers to be resent from cache.

Joomla confuses many with its terminology and "caching" has many meanings in Joomla (Its used to describe Object caching (like db results), HTML Fragment caching, View caching!)

avatar elpescador-nl
elpescador-nl - comment - 31 Aug 2021

@PhilETaylor , in my first comment I stated this works perfectly for J!3.9 (J!3.10) but I was mistaken. It doesn't work there either.
I've found a work around for this issue and using the page cache plugin on top of it prevents it from happening as it seems. So not a big priority I think.

Though it looks a bit strange to me that by activating the cache (and not the page cache) custom component headers are only sent when there is a cache miss.

avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 22 Feb 2023

Add a Comment

Login with GitHub to post a comment