Rule: only cache posts older than x days

#1
Hello
I am using ls Cache. Can we create a rule such as "Do not cache for posts published in the last 3 days" with the .htaccess file? I just want to cache for old posts but I couldn't.
edit:I do not use plugins. I activate the cache with htaccess. I use cpanel + litespeed on my server.
 
Last edited:
#5
Do you store the date of a published post? If yes, you can use this date and calculate with days to set no-cache header with PHP.
If you mean keeping it in the database, yes. Apart from this, I do not keep it with cookie or session methods.
date and calculate with days to set no-cache header with PHP. ::>
Can we do this transaction you mentioned with the date information to be taken from the database? Is there sample code for if yes?

Or can we purge the cache of a page specified with php code?
Thank you.
 

serpent_driver

Well-Known Member
#6
Is there sample code for if yes?
I don't know the code of your application, so you must find one who will develop it for you if you can't, but it needs only a few lines of code to compair the current date with the date when a post has been published. If this time period is passed remove no-cache cache header. That's it.

Code:
header('X-LiteSpeed-Cache-Control:no-cache');
 
#7
I don't know the code of your application, so you must find one who will develop it for you if you can't, but it needs only a few lines of code to compair the current date with the date when a post has been published. If this time period is passed remove no-cache cache header. That's it.

Code:
header('X-LiteSpeed-Cache-Control:no-cache');
This code will do the trick. Thank you so much. I will write again if a negative situation happens
 
Top