strange behavior. pdf void on second load

Phoca PDF - creating PDF documents in Joomla! CMS
nbit
Phoca Member
Phoca Member
Posts: 13
Joined: 02 Aug 2020, 11:03

Re: strange behavior. pdf void on second load

Post 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?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47794
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: strange behavior. pdf void on second load

Post 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
If you find Phoca extensions useful, please support the project
nbit
Phoca Member
Phoca Member
Posts: 13
Joined: 02 Aug 2020, 11:03

Re: strange behavior. pdf void on second load

Post 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) ?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47794
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: strange behavior. pdf void on second load

Post 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
If you find Phoca extensions useful, please support the project
nbit
Phoca Member
Phoca Member
Posts: 13
Joined: 02 Aug 2020, 11:03

Re: strange behavior. pdf void on second load

Post 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.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47794
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: strange behavior. pdf void on second load

Post by Jan »

Ok
If you find Phoca extensions useful, please support the project
nbit
Phoca Member
Phoca Member
Posts: 13
Joined: 02 Aug 2020, 11:03

Re: strange behavior. pdf void on second load

Post 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.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47794
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: strange behavior. pdf void on second load

Post by Jan »

Hi, thank you very much for this information, added to feature request list.

Jan
If you find Phoca extensions useful, please support the project
pepino69
Phoca Member
Phoca Member
Posts: 28
Joined: 04 Mar 2012, 21:39
Location: Czech republic
Contact:

Re: strange behavior. pdf void on second load

Post by pepino69 »

I still have the pdf in one folder and it opens immediately there. The problem is probably only on the front page
Post Reply