Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

compressed caching and serving compressed content
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
cyber
Smarty Regular


Joined: 08 Jun 2006
Posts: 51

PostPosted: Thu Jul 16, 2015 7:33 am    Post subject: compressed caching and serving compressed content Reply with quote

Looking to send compressed content back to browsers I found this article ( http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/ ) which I intend to try via .htaccess

This will still compress already cached content.

I was wondering if it has been explored already (or maybe exists already) to compress the cached content and serve that in combination with server settings ? It would save CPU/Memory resources as the cached content would not need to be compressed again and again.

If explored or existing, kindly point me in the right direction.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Jul 16, 2015 12:30 pm    Post subject: Reply with quote

Did you made measurements and determined, that the problem is, undeed, in lack of compression?
Back to top
View user's profile Send private message
cyber
Smarty Regular


Joined: 08 Jun 2006
Posts: 51

PostPosted: Thu Jul 16, 2015 12:35 pm    Post subject: Reply with quote

> Did you made measurements and determined, that the problem is, undeed, in lack of compression?

I'm not dealing with a problem as far as I can tell !!?
I'm asking if it has been investigated already (or maybe even implemented) to gzip cached files, to avoid having to do this on the fly again and again, and if so where is it documented ?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Jul 16, 2015 10:55 pm    Post subject: Reply with quote

If you are not dealing with a problem, then leave it alone.
Premature optimization will only lead to waste of time.
Also, the article you've linked is not relevant tp PHP. Which means, whatever you change will have no effect on script execution.
Back to top
View user's profile Send private message
cyber
Smarty Regular


Joined: 08 Jun 2006
Posts: 51

PostPosted: Fri Jul 17, 2015 5:58 am    Post subject: Reply with quote

It's very difficult to get a straight answer out of you isn't it ? I feel like I'm wasting my time, so I shall conclude it here.

I shall interpret this as 'No there is no such solution in Smarty that I know of' and/or 'the gain in cpu/memory usage is minimal compared to the time you need to put in to get it to work that way'.

Maybe you should also try not to tell people what is important to them in terms of functionality and time allocation
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Jul 18, 2015 12:32 am    Post subject: Reply with quote

If you know everything yourself, and just boast your ego by asking questions you don't need answers for, then I should assume you came here to troll people.
Othervise read my previous answer. You asking wrong questions and expect right ansers. That's just not going to happen.
You didn't even aswered my very first question. You just went on rambling about your question.
Back to top
View user's profile Send private message
cyber
Smarty Regular


Joined: 08 Jun 2006
Posts: 51

PostPosted: Sat Jul 18, 2015 7:09 am    Post subject: Reply with quote

There are no wrong questions AnrDaemon.

It is a fair question to which you never replied to the point. I still don't know the answer, I just deduced, from your aggressive-style replies, that that must be the answer, or you simply don't know yourself and you're just racking up points or something because otherwise you wouldn't have replied to the question to start with ?

So I'm still unsure at this point, but with the intent to close this thread, since I wasn't going to get a straight answer anyway, not from you at least, I surmised that what I must guess. Since you are 'Smarty Elite' and you have replied, you have taken 'ownership' of this question, and I doubt very much that other people will chime in now, especially after the tone of the messages. Nobody else wants to get involved now, and i can't blame them.

What first question ? I explained that I wasn't chasing a problem, I have no measurements, I simply wanted to find out if this is something that the more Smarty-savvy people have looked into already, and if so, where it is documented, so that I can have a look and see if it's worth it to implement.

Again, don't tell me what I have time for, or what I deem wasteful, I'm quite capable of doing that myself. All I need is some straight answers and I'll derive to whatever conclusion myself.

I have allocated a time slot for myself to work on the website, after that it's product development again, and I won't have time to optimize then. So whatever I can do now, and if it makes sense, I will do, hence why I have questions, to which a simply answer suffices.

Trust me, at this point I don't feel like I'm being the troll here, just (truly) wasting my time by trying to explain once more. But that aside, I have to take in account maturity and cultural background. Those are things not easily derived on fora like this and you may very well have good intentions, I'm just not feeling it, so let's close this thread in the interest of time and sanity.

Best.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Jul 18, 2015 7:24 am    Post subject: Reply with quote

First, I wasn't the one who invented the forum "rankings".
Second, you didn't even checked, if your scripts return compressed content. You just saw a ten years (good if only ten! From the points explained, it could be twenty) old article about some stuff you don't understand and came here asking if Smarty could do it by enabling some parameters in .htaccess.
And instead of answering my first question (is that indeed the lack of compression, that affecting your site?), you went on rambling on how incompetent I am.
You even wrote a whole wall of text about it. Do you feel better by now?
Back to top
View user's profile Send private message
cyber
Smarty Regular


Joined: 08 Jun 2006
Posts: 51

PostPosted: Sat Jul 18, 2015 6:53 pm    Post subject: Reply with quote

I did not intend to respond anymore as I'm not going to get a good answer from you, but all your post does is tell me that you still don't understand ? So I shall try again ...

AnrDaemon wrote:

Second, you didn't even checked, if your scripts return compressed content.


I actually did but that is entirely besides the point, in fact if Smarty did that by default I would deem that an unnecessary resource drain, since the data needs to be served uncompressed, under normal circumstances, and HD space is usually not the problem these days.

AnrDaemon wrote:

You just saw a ten years (good if only ten! From the points explained, it could be twenty) old article about some stuff you don't understand


Sigh.
The age of this article is completely irrelevant. Its content on the other hand is very relevant. It is a good way to send all text content Gzipped to the browser of the visitor, in most cases speeding up the surf experience and even helping with seo a bit etc.

The article shows how to trigger Apache to gzip (compress) all data to browsers, on the fly. I actually understand the article very well, including the deeper mechanics of it all. I included it to illustrate what I'm referring to.

Once setup (in .htaccess (or per php file) and WHM) all data, when requested by the user, is compressed on the fly. If one uses the Smarty cache extensively, as I do, this means that unchanged, cached, content is compressed on the fly again and again. The same pages many many thousands of times per day, sometimes per hour.

AnrDaemon wrote:
and came here asking if Smarty could do it by enabling some parameters in .htaccess.


No, I asked if it has been explored already (deemed possibly or not) to (pre-)compress cached content in combination with server settings/.htaccess or in the php code itself so that the step of having to gzip cached content on the fly (by Apache) can be avoided. It would save on cpu and memory and in times of high traffic may even speed up the surf experience.

I don't know how to put this simpler for you ?

Does the Smarty-Elite know of a way, or has it been explored, investigated, discussed already, whether this is possible ?
Surely I'm not the first person to come up with this ??
gzipping content sent to browsers is pretty standard stuff these days.
So maybe there's a way somehow to already gzip the cached files (maybe with Smarty ?) and tell the browser + Apache (via php, send a header for instance (maybe functionality in the Smarty class or something I set myself ?) that the page is zipped already and doesn't need to be gzipped on the fly this time.)

I hope you understand now ?
Maybe I get a straight answer then.

AnrDaemon wrote:

And instead of answering my first question (is that indeed the lack of compression, that affecting your site?),


For the Xth time, my site is not 'affected', I'm just doing a big overhaul and want to make sure it works as best as possible before I start doing other things again and may not have time for months or even years (except for changing content itself).

AnrDaemon wrote:

you went on rambling on how incompetent I am.
You even wrote a whole wall of text about it. Do you feel better by now?


My ramblings are trying to get through to you, which is not an easy task.
Don't put words in my mouth, I did not call you incompetent, but if that's how it makes you feel ...
I don't feel good at all. I am putting time in something I don't want to put time in without much prospect of a good answer.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Jul 18, 2015 10:08 pm    Post subject: Reply with quote

I already told you, you're asking impossible question.
But you are still pretending, that your question is right and you know better than anyone else.
You even insist that you are right, throughout the topic, even though everyone reading it laughing out loud.
Sorry, but I refuse to deal on such terms.
Go read http://www.smarty.net/about_smarty until you understand, what Smarty actually is. (Hint: it is a PHP library that is intermediate to your code and has nothing to do with output compression at any point ever.)
Your. Question. Is. Simple. Wrong.
Back to top
View user's profile Send private message
cyber
Smarty Regular


Joined: 08 Jun 2006
Posts: 51

PostPosted: Sun Jul 19, 2015 7:49 am    Post subject: Reply with quote

Sigh ...
It's a good question, and the ones that aren't laughing, and actually understand the deeper mechanics, will agree. I may not work, that is something else, but it is certainly not a bad idea.

I know what Smarty is ... that's why I use it. My question was merely to find out if in this community it had been discussed already to pre-gzip cached content and serve that instead of letting Apache do it on the fly, again and again. It's something easily conceived abstractly, I just wondered if it had been explored, discussed, tested already and what the pitfalls were.

But anyway, thank you, yes, don't 'deal on such terms'. Let other more knowledgeable people chime in.

For the benefit of others that are looking into this as well, not the ones laughing (supposedly), I'll try a few things later this week. I don't know if I will bother to update this thread however, it is tainted, but at least you can Google for the following (PS. this may not work well enough to replace simply letting Apache do it (hence why the OP in the first place), but anyway)

What comes to mind is to check if the browser accepts gzipped content, via: $_SERVER['HTTP_ACCEPT_ENCODING'] and set $accept_gzipped

Save and use two cached versions, one gzipped and one not
if(!$smarty->isCached('index.tpl', $accept_gzipped))

Use an output filter to gzip if $accept_gzipped is set (and if not yet cached) (syntax not yet explored, in the filter I would let php do the gzipping).

Send a header command ( Content-Encoding: gzip ) This may actually be the tricky part as it may prevent Smarty to send further data (needs to be tested)

$smarty->display('index.tpl', $accept_gzipped);

In the .htaccess I would only set to use Apache's on the fly compression for javascript and xml then, not html, so that that is done as well, but at least Smarty-cached content is not re-gzipped all the time, possibly 1000's of times per minute (which of course is an interesting discussion topic as well because Apache may very well have this optimized as well in memory so that it would in fact be much faster than anything else ... hence why, again, the OP)

If only a knowledgeable person had responded, because I'm fairly sure I'm not the first person to come up with this.

Anyways please, 'don't deal on such terms', stop trolling this post.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Jul 19, 2015 7:45 pm    Post subject: Reply with quote

You're just stupid.
http://php.net/manual/en/zlib.configuration.php#ini.zlib.output-compression
Has. Nothing. To. Do. With. Smarty.
Back to top
View user's profile Send private message
cyber
Smarty Regular


Joined: 08 Jun 2006
Posts: 51

PostPosted: Mon Jul 20, 2015 6:58 am    Post subject: Reply with quote

I didn't expect another reply from you AnrDaemon.
Your link, as well as your input on this thread, is useless.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Jul 25, 2015 6:45 pm    Post subject: Reply with quote

I see the following possibility:
Check $_SERVER['HTTP_ACCEPT_ENCODING']
If gzip can be used:
- Set up a cache_id like 'gzip' or other.
- Load the output filter. You could use isCached() check to load it only when the cache is invalid.

NOTE: If your template does contain nocache code the output filter does not run when cache file is created, but when the page is displayed.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Jul 26, 2015 4:40 am    Post subject: Reply with quote

PHP already does that.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP