How to disable / exclude Caching for a specific .php file?

#1
As the title says how can I disable / exclude a .php file from being cached by LS?

When I use a caching plugin such as Hummingbird, all I have to do is add the following line to the top of the .php file in order to exclude it from cache:
"define('DONOTCACHEPAGE', true);"

Thanks in advance!
 

Attachments

serpent_driver

Well-Known Member
#2
Code:
<IfModule LiteSpeed>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/filename\.php
RewriteRule .* - [E=cache-control:no-cache]
</IfModule>
Or got to: wp-admin/admin.php?page=litespeed-cache#excludes if you use WordPress
 
Last edited:

Crazy Serb

Well-Known Member
#3
Code:
<IfModule LiteSpeed>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/filename\.php
RewriteRule .* - [E=cache-control:no-cache]
</IfModule>
Or got to: wp-admin/admin.php?page=litespeed-cache#excludes if you use WordPress
Ok, but how would that work for include(), include_once(), require() and require_once() files, for example?

If we have a include_once("file.php"), how do we get the file.php to be excluded from caching?
 

Crazy Serb

Well-Known Member
#5
Litespeed cache works based on URL, which is why it is not possible with PHP to limit caching to included files. But there is ESI (Edge Side Includes) to make almost the same.



https://docs.litespeedtech.com/lscache/devguide/advanced/#esi-example
https://www.dev.cachecrawler.com/esi/
Ok... my question again is HOW?

I tried the example from https://docs.litespeedtech.com/lscache/devguide/advanced/#esi-example and that produced literally nothing - didn't even include / print out anything from the esi:include src=... file.

if I have a require_once("/home/domain/file.php"); line that I want to exclude from caching (and any content that file prints out), HOW do I get that done?

Can you post an example of what you're talking about here, relevant to my question above?

Thanks.
 

Crazy Serb

Well-Known Member
#7
You can't use PHP include for ESI src="". ESI is a Markup Language like HTML and the ESI source for including must be included on the same way you use any other source in HTML.

Read how ESI works: https://blog.litespeedtech.com/2014...s-esi-support-will-speed-up-web-applications/
and the complete documentation about ESI: https://docs.litespeedtech.com/lscache/devguide/advanced/#esi
I have read that documentation 3 times.

And you mentioned that "there is ESI (Edge Side Includes) to make almost the same" as what I asked for in your comment above, so if ESI can "make it almost the same", HOW is that done specifically?

I am not looking for links to documentation as I haven't seen a single example of what I'm looking to do in any sort of documentation anywhere on the internet, so linking more docs and examples of how this is usually done probably won't help.

If you have a specific suggestion of how to what I'm looking to do, please post it here, clearly and with code examples. Otherwise, more links won't help my cause, I can tell you that right away... I've Googled this into oblivion with no luck.
 

serpent_driver

Well-Known Member
#8
Unfortunately, you still seem to lack an understanding of what ESI is and what you can do with ESI. That's why a code example doesn't help you, although the documentation shows you such a code example. I can therefore only give you the advice that you deal intensively with the documentation. In it you will find everything you need so that you are able to either exclude certain content areas within an HTML document from caching or define a different caching behavior.
 

Crazy Serb

Well-Known Member
#9
Unfortunately, you still seem to lack an understanding of what ESI is and what you can do with ESI. That's why a code example doesn't help you, although the documentation shows you such a code example. I can therefore only give you the advice that you deal intensively with the documentation. In it you will find everything you need so that you are able to either exclude certain content areas within an HTML document from caching or define a different caching behavior.
So what you're really saying is that you don't really know yourself what you're talking about in this case, and keep referring to "documentation" for me to fish out and find examples of how this actually works in my case, because you just don't know yourself and can't provide an example yourself...

Got it.

I've gone over that documentation enough times and it doesn't provide an example of how to do what I need to do (other than some remote scenario of using functions.php and shortcodes/widgets/blocks of some sort, which has nothing to do with my scenario and is a round-about bandooloo way of doing this), so here, I'll challenge you instead - if you can't provide the actual code you're referring to as "doing almost the same" thing as limit caching of files like I am asking for, I'll assume that you really have no clue what you're talking about and have no business sharing any sort of advice in this forum, and are only responding to people's threads with some vague comments in order to bump up and promote your own service/business.

Prove me wrong.

I'll wait...
 

serpent_driver

Well-Known Member
#10
So what you're really saying is that you don't really know yourself what you're talking about in this case, and keep referring to "documentation" for me to fish out and find examples of how this actually works in my case, because you just don't know yourself and can't provide an example yourself...
Of course i know it! Who do you think has developed a ESI:inline solution like this?
https://www.dev.cachecrawler.com/esi/

You've already signed up with Wordpress Support, which is why you'll get proper support for the LiteSpeed cache plugin for Wordpress there. This forum no longer provides support for this plugin. Please contact the support in the Wordpress forum.

I recommend that you make your choice of words a little more friendly. You are a supplicant, so act accordingly please.
 

Crazy Serb

Well-Known Member
#11
Of course i know it! Who do you think has developed a ESI:inline solution like this?
https://www.dev.cachecrawler.com/esi/

You've already signed up with Wordpress Support, which is why you'll get proper support for the LiteSpeed cache plugin for Wordpress there. This forum no longer provides support for this plugin. Please contact the support in the Wordpress forum.

I recommend that you make your choice of words a little more friendly. You are a supplicant, so act accordingly please.
I recommend you stop claiming things that you cannot back up. It doesn't instill much confidence in you or your service that you developed there when you can't answer a seemingly simple question in a straightforward way but have to beat around the bush and go about it the most round-about way possible, just suggesting to "read the documentation, it's all in there" kind of a solution.

Again, I don't think you know what you're talking about when it comes to this specific issue, regardless on how many tools you might develop for Litespeed, until you provide an actual solution to what you claim you know is possible.

And don't refer to people as supplicants, it's bad for business, you know.
 

serpent_driver

Well-Known Member
#12
With provocations you achieve exactly the opposite. You will therefore no longer receive any support from my side. Therefore, contact the LiteSpeed Support in the Wordpress forum that is responsible for you.
 

Crazy Serb

Well-Known Member
#13
With provocations you achieve exactly the opposite. You will therefore no longer receive any support from my side. Therefore, contact the LiteSpeed Support in the Wordpress forum that is responsible for you.
I am sorry you feel that way, but I am not provoking you. I am just calling out spade a spade, calling out what I see, in the open. Again, I am waiting for you to prove me wrong, after which I will gladly take back everything I said, but somehow I don't see that happening from your end...

And don't worry, I haven't received any support from you here at all, so no loss on my end. And yes, I am in touch with WP support instead...
 
Top