Caching - Implementing Cache With Maximum Size Of Cache Folder?
I need to implement cache for my PHP web application. I implemented the cache file control (saving and getting files from cache dir) but now I need to enforce cache folder max size control, because cache folder should be limited in max size.I had an idea to limit the size by deleting the least used files when the space is needed. Now, I've read that using the fileatime function on all the files in cache dir would slow down my application.Is there any other method that springs in your mind?
(DB (MySQL) usage for storing last access time for cache files is, unfortunately, unimplementable.)
APC: Opcode Cache Versus User Cache - Set Separate Limits?
I am trying to move from the typical combination of APC (for opcode) and Memcache (for my userdata) to a purely apc based cache. Given my usage structure it makes sense and performance is higher. But unlike before, where the apc cache was limited to a reasonable size and did not affect my data cache, I am now worried that the opcode cache might grow relatively large so that the sum of opcode cache an datacache exceeds the limit. As far as I understand, this would result in a flush of the total cache.Is there a way to mimic the behaviour, as if apc was only an opcode cache and limit the opcode cache size to a reasonable limit, leaving the rest for user data? Or should I try setting lower ttl values for the opcode cache, so it always gets flushed first?
Zend Cache Core And APC - How Old Cache Entries Get Invalidated?
For Zend_Cache_Frontend_Core you can define a lifetime and, according to the documentation, a "automatic_cleaning_factor".According to the manual, this property specifies on how many writes to the cache old cache entries get invalid.When I use APC as backend shouldn't the cache invalidate itself automatically without having to write to the cache?Or did I misunderstand something there?
As you know, ezSql has a useful caching feature. I'm newly using this but when i edit anything on database, i'm deleting all cached files, and waiting for caching them again. I'll explain it with an example, There is a page ([URL]) which listing user's datas (username, city, phone etc..) .
I'm caching all queries on user.php file and all users' datas caching seperately. When some user (John) update own datas. When this happened, i'm deleting all cache files, so i'm deleting all user's cached datas. Are there any way to deleted (or refresh) only John's datas cache? What do you think, is it possible ? You know cache files names is hashed (like this: 6f3b84011a8693ad7e5b86c6dff3d27d )
Why Is APC Incrementing "Cache Full Count" For User Cache Even Though It Has Plenty Of Memory Available
I've played with this for quite a while but am at a bit of a loss as to what to do. I'm using APC 3.1.3p1 on CentOs 5 with PHP 5.2.5. APC is acting as both the opcode cache and user cache. Mostly this server runs Drupal 6 sites using the CacheRouter module for APC cache support. I was running APC 3.0.19 for a while but it was causing Apache to lock up occasionally (a documented bug in that version of APC) so that's why I'm on 3.1.3p1. I've configured APC to have 512 MBytes of memory (mmap). The symptoms are a little intermittent but starting from an empty cache this is generally what I see:
The user cache fills rather slowly. Despite an initial insert rate of something like 20,000 inserts/sec, the user cache will only report a few hundred, then a few thousand entries, and will grow very slowly. I can possibly attribute this to write_locking being on but just want to mention it in case it's of importance in solving the problem at hand. After several hours it hits an equilibrium of around 30k entries. Fragmentation sets in early and grows quickly. Within maybe 10 hours or so I'm usually at 100% fragmentation. Overall (opcode + user) cache usage stabilizes around 240MB or so. It will virtually never go above that level. After a day or so I'll start seeing the User Cache Cache Full Count (UCCFC) incrementing.
At the time of this writing my UCCFC is at 62358 and growing despite APC reporting 280MB free. I have a user_ttl of 7200, but I've also played with setting it to 0 or other amounts and it has little to no effect on the problem. I suspect the problem has something to do with fragmentation. Right now my server is reporting "Fragmentation: 100.00% (280.0 MBytes out of 280.0 MBytes in 24740 fragments)" and 280 MB just so happens to be the amount of free space APC is reporting; a telling coincidence, I think. Unfortunately, I've found precious little information in the docs or elsewhere to indicate just what "fragmentation" truly means in the APC world, and there seems to be virtually nothing you can do to avoid it.
I was paying with my code and put in a couple of lines that did not work....so ok I changed my mind just cut off the new lines so in a way the rest of the code was never touched but I keep getting this error over and over ...and nothing has changed it workrd just fine before. So what is that?
---------------------------------------------------------------------- Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/public_html/search.php:2) in /home/public_html/conn.php on line 36 ----------------------------------------------------------------------
Person logs into website to place an order - adds a couple products to their cart... then adds another item... but all previous items are gone - just the newest item is there. I've figured out this issue, and all the items are in the database, but for some reason, a new session ID was generated along the way. When that happens, the customer thinks they lost the items in their cart.
I have only been able to recreate this issue with IE, but... 98% of our customers use IE.
Customer Logs in as USER1... browses around. Then logs out and logs in as USER2... but the site is still showing as USER1 (at the top of each page it says "Welcome USER1").... BUT, if the person holds their Ctrl+Refresh (to force a Refresh in IE) - it will show them what they should see "Welcome USER2".
Both issues are extremely frustrating and I cannot find the cause. Below is some info I'm hoping someone can look @ and recognize the problem.
I used the php header and no-cache, but why it works on some computer, and not on some computer? Is there a way to fix this problem? I would like the random image to change every time of refresh or F5.
When dealing with a large amount of pages, is it better to dynamically create from the database then cache each page in a folder, or to dynamically create it using info from a database every time someone access's the page?
I'm working on an e-com. store and the client wants it so that after you checkout if you hit the back button it skips all the previous pages in the cart and takes you back to page before you enter the cart. From what I've read it seems like I can force a page to not cache but I don't want the pages in the history at all... is there a way to do this?
I have a little script that takes the data from a user filled-in form, and then generates a pdf file with the content. Between the actual filling in of the form and the generation of the pdf file, there is a confirmation screen where the user sees the values he/she is submitting and confirms wether they are right or not.
The problem is that if they spot an error and go back to the form (using the back button), they get a message saying that the page contains POSTDATA that has expired from cache etc... and when they get the form back, it is blank.
But the pages will not get refreshed with new visits even after several days, or even with Refresh. (however on IE, CTRL+F5 would bring the updated page). Do you have any idea on what I am missing. Here is the returned header for that page:
Result code: 200 (OK / OK) Date: Sat, 04 Mar 2006 12:37:58 GMT Server: Apache/1.3.33 (Unix) mod_tsunami/3.0 Cache-Control: private, max-age=60, pre-check=60 Expires: Thu, 19 Nov 1981 08:52:00 GMT X-Powered-By: PHP/4.3.2 Set-Cookie: PHPSESSID=95817bf8b4d7eb3435797b2fd9f09636; path=/ Last-Modified: Tue, 21 Feb 2006 07:43:07 GMT Content-Type: text/html X-Cache: MISS from wc02.inet.mesa1.secureserver.net Proxy-Connection: close
Most of my application's operations (including SQL queries and numerical computation) can be cached. An LRU (least recently used) cache would fit the bill perfectly.
This LRU cache should be preserved over multiple requests from the same session. If possible, it should be seen across multiple sessions so that all users can benefit from it.
I can't implement either solution. In principle I could preserve the cache across multiple requests by using $_SESSION, but I don't think this would be wise. The whole structure would weigh on the order of a MB, so access would probably be really, really slow.
Also consider that access to the cache must be serialized.
I could in principle write the C code to do the caching. But this would be extremely ugly since I want to cache PHP objects, not C structures. There would also be the overhead of converting to and from PHP's representation.
I have a php file which will list the pending task for each developer. If the developer changes some thing it will update to database. Once the user clicks the update button it shows the another page and there will be button back to list of pending task. It will again fetch from database.
At the second time if user update some other data. It giving me the old data list also.
I used ClearStatCache() this is not working. And also I added
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="expires" CONTENT="0"> in my php file.
I have a page that creates an image with imagePNG function and saves it to disk. Beside the image, there is also a form on the page, in which you can change the imagage data. When an user submits the form, then the same page is called, and the different image should be displayed (with the same name). Problem : the image stays the same, the image file changes ; PHP Code:
I've such problem I'm trying to solve. My images are numbered xxxx-1.jpg, xxxx-2.jpg, xxxx-3.jpg (where xxxx is the article number).
Now, when the used deletes the 2nd pictures, then I update the database for having the xxxx-3.jpg renamed in xxxx-2.jpg and also I rename the file on the server.
Problem: if I go to the article page, then the OLD xxxx-2.jpg is shown. I've to refresh with CTRL pushed to get the correct image. Also if I come back to manage those pictures again, then the third is definetively removed, and the xxxx-2.jpg shown the old one, not the xxxx-3.jpg renamed.
How to avoid the server to store such think ? I don't want the cache for such pictures.
I want to keep Proxie Servers and the Browser Cache from storing my page - to provide always a new version. I didn't have any success with meta HTTP-EQUIV tags, now I want to try it with PHP headers. Does the following code work?: PHP Code: