I would like to use the output caching function in CodeIgniter, it is simple & fast enough for my application. But the problem is CodeIgniter will push all cached files (hashed names) into the same folder, that will be a problem in my case where I have to cache about 150.000 static pages.
That huge number of the cached files does obviously slows down the process for each request. In my case, I can separate these static pages into multiple categories, so I am thinking of if I can handle CodeIgniter cache to work over the multiple cache folders, it would speed up the process.
Can anyone help me with any suggustion?
Thanks and regards,
Leo
If you really want to separate your cache files into subfolders, MP_Cache (http://hg.mijnpraktijk.com/mp_cache/overview) might help you. But be warned that MP_Cache is no longer maintained by the author.
Related
I plan to use this template on my website for my spring boot web application:
https://github.com/puikinsh/gentelella
I have downloaded it and plan to just customized the pages to suit my needs. However, upon downloading it has a lot of folders one of which is vendors which contains a lot of js libraries amounting to 87.1 MB. I'm certain I won't be needing everything, my website will only contain a few CRUD pages and that would be it.
How should I use this template? Isn't there a simple example page that I can use and then just add the stuffs that I need one-by-one? instead of using all these files and deleting the ones that I won't be needing (I don't even know which to delete)?
Sorry if this is a noob question. But I hope I make sense.
Any help appreciated.
We have 2 million businesses in our database. My client wants to create 1 static page for each business so that the pages are indexed by Google. He wants each page to have the following URL structure:-
http://website/business-name/category/city/zip/
So an example page could have the URL:-
http://example.com/pizza-hut/restaurant/newyork/12345/
What I want to know is the disadvantages of making this much static pages and any advantages they have? Thanks.
A clear disadvantage is that this makes a lot of files to manage, for you, the server, the cache system, the file system and the source control system.
And that's totally useless as you can can let the rest of the world, including Google bots, think there are different pages without making different pages, using htaccess rules : they allow URL rewriting.
There is no difference between a static and generated web page to Google. It will crawl the page if there is a link to it. If there is no link to a static page it has no way of finding it. So there is no advantage of a static page unless it is faster to read from disk then to generate on the fly.
For an (enterprise) web project i want to keep previous versions of the static files so that projects can decide for themselves when they are ready to implement design changes. My initial plan is to provide folders for static content like so:
company.com/static/1.0.0/
company.com/static/1.0.0/css/
company.com/static/1.0.0/js/
company.com/static/1.0.0/images/
company.com/static/2.0.0/
company.com/static/2.0.0/css/
company.com/static/2.0.0/js/
company.com/static/2.0.0/images/
Each file in these folders should then have a cache-policy to cache "forever" -- one year at least. I also plan to concatenate css files and js files into one, in order to minimize number of requests.
Then i would also provide a current folder (which symlinks to the latest released version)
company.com/static/current/
company.com/static/current/css/
company.com/static/current/js/
company.com/static/current/images/
This will solve my first problem (that projects and sub websites can lock their code to a certain version and can upgrade whenever they are ready).
But then I can see some caching issue. Now i cannot "just" cache current folder, since it will change for each release. What should my caching policies be on that folder.
Also, for each release, most of the static files will never change anyway. Is it relevant to cache them forever, and rename if there are changes?
I am looking for advice here, since i want to know about your best trade-off between caching and changing the files.
Beware of HTTP caching. I looked into this some time ago.
my blog article on the HTTP caching
There are three approaches you can select from:
Use resource's path as a cache key, i.e. when it changed - the browser will have to download new version of your resources. In this case you don't need /current folder at all, you just need to avoid .html page caching and put appropriate path to your resources in it.
You can point browser to /current folders only and add ETag to your resources, in this case another server request will be made from the client, but it will be conditional request (i.e. with If-None-Match header), so you can return 304 response (with no resource body) until your customer decide to migrate to another version. Another drawback of such solution (if you have several customers who use different versions) is that /current folder will contain only some single version of the design.
As you're going to concatenate resources into single files, you can specify resource version as part of url: /current/js/combined.js?version=1.0.0.0 But this is not much different from first approach.
Hope this helps.
It might be worth your while looking at how Google, Microsoft etc. have implemented the caching policies for their jQuery CDNs
Your policy of caching forever is OK for the versioned URLs.
For the current URLs you're obviously going to need a shorter expiry time.
Couple of things to consider:
How are the applications going to be able to test against /current/ i.e. if they use it how do you know a change isn't going to break an existing application?
Caching forever is only really about reducing requests during the 'current session' as most browser caches aren't big enough to hold files for a long time (they get removed as people browse others sites)
I have a website that uses CakePHP 1.3.10. This CakePHP app it's pretty big, not in the amount of models or controllers (like 5 of each), but in the amount of plugins. I use the plugins as places of the website where users can access (or can't access) depending on if they have logged in already or not (well there's more reasons, but it's not important now, it's how it works). I also use a global Auth component in the app_controller.php
My issue is the following: I've noticed that the website is getting really slow when trying to access any of the pages of a plugin (when accessing the "home" page - which is not in a plugin - all is good).
The thing is that I was going to run some performance tests to figure out what's going on. I decided to create another website, exactly like the one I described, with the only difference that I removed all the plugins with the exception of one.
Amazingly (for me), when I access one of the pages of this plugin that I didn't delete, it goes super fast, like it should normally go.
So my question is: does the number of plugins really have a direct impact on the loading times of a page inside those plugins? Is there any way to "fix" this? Or is it just a coincidence and something else is going on that I missed?
Thanks so much in advance for any advise!
Reducing the amount of files and folders of my application has increased significantly the load times. I don't know what is the relation between amount of files/folders and loading speed in CakePHP, but it's a fact, at least in my website.
I've changed my cake installation to an advanced installation (as it explains in the cakephp boo) to have my files more spread out in different sub-apps, instead of having one huge app, and this has helped a lot!
I'm trying to implement caching in code igniter. I'm completely new to this so it might be a dumb question but lets see if there's an answer out there.
I've gone to database.php and enabled caching and placed my path. I believe the path is fine because my delete all files call removes the index.html and the htaccess file from that folder. However nothing gets cached as I use the app. I've tried to turn cache on using $this->db_cacheon() but nothing seems to write any files to that folder. My setup is that I have models to handle the connection to the database table in question. So inside of that model I would do a select from tablename and try to have that cached but nothing seems to happen. Does anyone have an idea what I could do to fix this?
There are three types of caching. I don't know much about database caching. I have done output caching.
$this->output->cache(n);
Whatever page you want to cache,
you can use this in controller function which loads your view page.
You can find your cache pages in system/cache folder.
Do you mean $this->db->cache_on()
Have a look at the manual:
http://codeigniter.com/user_guide/database/caching.html
http://codeigniter.com/user_guide/libraries/caching.html