r/PHPhelp • • Feb 24 '25
Restrict access to cached files CodeIgniter
I am caching some data using the output class in CodeIgniter 3.13. but the problem is that data is accessible to unauthenticated user due to how output class works (it first checks if the cached file exists and serves it and if it doesnt then it inits the controller and does the check access) Any idea how can I prevent this?
More context: the cached data is used for dashboards and data is refreshed every hour or two, also anyone can access that data when entering the url in the address bar and CodeIgniter serves the cached data... So if you type url/Dashboard/dashboardData , codeigniter would serve you the data if it is cached
View all comments
Show parent comment
1
u/MateusAzevedo Feb 25 '25
You're tackling the problem from the wrong angle. HTTP response cache is not the correct solution for this purpose.
As said, you need a cache feature in the application level, like this. Then you only cache the data, but still go through the whole request process, auth, controller, etc.