litespeedtech / openlitespeed

Our high-performance, lightweight, open source HTTP server
https://openlitespeed.org
GNU General Public License v3.0
1.15k stars 188 forks source link

When the entry PHP script is modified, the cache is cleared. #406

Open ziaratban opened 1 month ago

ziaratban commented 1 month ago

I rewrite all non-files or directories in "index.php" and cache some requests based on conditions , so when the content of the index.php file is updated, all the cache is cleared.

litespeedtech commented 1 month ago

should the cache be cleared or not? what's the current behavior?

ziaratban commented 1 month ago

should the cache be cleared or not?

It should not be cleared.

what's the current behavior?

cleared.

AndreyPopovNew commented 1 month ago

@ziaratban you again about opcache?

check opcache settings https://www.php.net/manual/en/opcache.configuration.php

opcache.validate_timestamps opcache.revalidate_freq

ziaratban commented 1 month ago

@AndreyPopovNew thanks for reply.

I am talking about the internal module cache in lsws. opcache is disabled.

ziaratban commented 1 month ago

should the cache be cleared or not? what's the current behavior?

Module Parameters :

checkPrivateCache   1
checkPublicCache    1
maxCacheObjSize     10000000
maxStaleAge         200
qsCache             1
reqCookieCache      1
respCookieCache     1
ignoreReqCacheCtrl  1
ignoreRespCacheCtrl 0

enableCache         1
expireInSeconds     3600
enablePrivateCache  0
privateExpireInSeconds 3600
AndreyPopovNew commented 1 month ago

@ziaratban are you about lscache?

by your settings lscache expired after 3600 seconds (1 hour)

lscache store cached pages (even dynamically generated) as static HTML files

by default, if you change any page (code of page) then lscache purge cached page and not create new cached page until next page request.

depending from settings lscache can purge:

ziaratban commented 1 month ago

if you change any page (code of page)

This is exactly the problem, it doesn't make sense for dynamic pages. The worst case is that I cannot update the source of my program on the server. If the program source is updated, my dynamic pages will also be removed from the cache.

I think this needs to be handled by settings or headers.

AndreyPopovNew commented 1 month ago

This is exactly the problem, it doesn't make sense for dynamic pages.

exist ESI - https://www.litespeedtech.com/products/features/edge-side-includes but OpenLiteSpeed (OLS) not support this. only LiteSpeed Web Server (LSWS)

ziaratban commented 1 month ago

Thank you for your solution. I still think this feature is one of the essential issues in lscache. Otherwise, the use of lscache in external applications is incomplete. (for example in lsphp)

@litespeedtech what is your opinion?

litespeedtech commented 6 days ago

I am not sure why a staled cached page is preferred over updated page reflecting the most recent change. I think most people want to see the change immediately. It has nothing to do with ESI. If you do not want to get slow loading page after update the code, then configure a crawler to warm-up the cache immediately.

ziaratban commented 4 days ago

As you are aware, in php frameworks and especially in the world of object orientation, compared to the traditional mode (such as WordPress), everything starts from an index.php file or entry script so that the entire system flow is controlled by the framework (such as yii2 or Laravel). Therefore, all requests go to one file, and therefore cache control must be managed in one file and in the framework layers. If openlitespeed is supposed to delete the entire cache by updating the index.php file, it is not logical. Apart from this rule, the world of external apps is a dynamic world, this dictates that we leave the control of the cache completely at the disposal of external apps.

This current behavior of cache module in openlitespeed is responsive for static files.