Page 2 of 2

Re: strange behavior. pdf void on second load

Posted: 16 Sep 2020, 10:34
by nbit
Hi Jan,
I have some difficulties to follow you cause the topic is too technical for my abilities.
Btw thanks for you replies, I will try to study it so I can better understand the problem.

I have one question, dunno if you already replied in your previous comments. First time I open a pdf it works correctly, that means that independently by the com_content article cache status, it is still able to call your script and generate the pdf at least for the first time. Since the second attempt I get the problem cause as far as I understand there is a cache uncompatibility.
Is it possible the first time the pdf is generated and your script is called for it, to wipe the cache for that file so it keeps generating the pdf?

I mean, when the first time the pdf is generated, something is added to the cache, can your script remove that something from the cache after generating it the first time? So com_content can act normally but we just remove the cache for the pdf so com_content will keep calling your script instead of using the cache cause it won't find the record in the cache?

Re: strange behavior. pdf void on second load

Posted: 17 Sep 2020, 11:46
by Jan
Hi, this is the flow:

1) First time - Article component loads the data, render the page and ask if Phoca PDF wants to create PDF instead of HTML
2) Second time - Article component does not load the data, does not ask Phoca PDF and shows directly the cached content in HTML

So second time, Phoca PDF is just not even asked to do something, this is why it cannot influence this process :-(

Jan

Re: strange behavior. pdf void on second load

Posted: 17 Sep 2020, 23:13
by nbit
yes I had some clue about that,
so what I mean is, isn't it possible to do something on phase 1) for preventing the caching of the pdf view or to remove the cached record so in phase 2) com_content doesn't find the record in the cache and goes back to 1) ?

Re: strange behavior. pdf void on second load

Posted: 22 Sep 2020, 12:25
by Jan
Hi,

seems like it is not possible to delete the cached file in phase one because it is written after Phoca PDF will do something. So the second idea to prevent from caching is the only chance. I tested this but didn't find any other place accepting the cache options as the com content controller. I will try to do more tests, but for now really no clue advice as the only one place to do, I found, was the com content controller :-(

Jan

Re: strange behavior. pdf void on second load

Posted: 22 Sep 2020, 16:15
by nbit
thanks Jan,
really appreciated, i will try to play around a little bit as well, I really would like to solve this issue cause i need both, pdf and cache.

Re: strange behavior. pdf void on second load

Posted: 25 Sep 2020, 13:49
by Jan
Ok

Re: strange behavior. pdf void on second load

Posted: 01 Feb 2021, 20:15
by nbit
Hi Jan,
I think I found a workaround inside phocapdf files, so we don't have to modify com_content files which is not a good approach.
I added into content.php of phocapdf content plugin these lines on row 22 after onBeforceCreatePDFContent

$contCache = JCache::getInstance('callback', array('defaultgroup' => 'com_content'));
$cacheID = md5(serialize(array(JCache::makeId(), 'ContentViewArticle', 'display')));
$contCache->remove($cacheID);

I wasn't able to prevent com_content from caching the item, but I was able to remove the item from the cache using its MD5 id.
As far as I can see, it doesn't wipe com_content cache completely, but it just removes the cache for that particular item.

Feel free to improve this approach and to make it perfect, can you please merge it into next phocapdf update? I always forget my custom modifications so the best way to manage it is if you can merge this into the main branch.

Re: strange behavior. pdf void on second load

Posted: 02 Feb 2021, 03:04
by Jan
Hi, thank you very much for this information, added to feature request list.

Jan

Re: strange behavior. pdf void on second load

Posted: 02 Dec 2022, 19:54
by pepino69
I still have the pdf in one folder and it opens immediately there. The problem is probably only on the front page