File persistently cached in Yii despite overwrite - caching

I have this weird problem with one of our file. It's named Setup.php and stored under protected/components/
This file is mainly for emails, header, footer generating functions etc. We found out few days back that when we changed the footer layout in this file, the old footer would still show, despite doing a lot of debugging and edits (even removing the footer function itself), it still shows the old one. This is a shocker. I'm aware of cache issues but does Yii cache the whole PHP file? Is this even possible? We are positive the footer used the same function from the same file.
I'm again having this issue with another function in the same file. Determined it's a problem with the component file and Yii, I would like to seek assistance from the Yii users.
Please let me know your thoughts. Thanks in advance.

Related

How to prevent browser from loading the old source

Edit : I don't know if it actually loads from cache, so I can't create the question named "prevent from loading cache".
Problem : Browsers sometimes save my code and keep loading only the code they saved(Maybe it saves in the cache). When this problem occurs, browser is like caching the old code and won't change anything. This is to say, It won't load any new code I updated.
Information: This occurs in HTML, CSS, Javascript on all browsers. I am using Apache in XAMPP as an appserv.
Deleting cache in all browsers won't fix this.
My first way to stop this is to delete the file, refresh browser and replace it.
The second ways is changing the pathname.
After the fix, the problem will occur again at anytime :(, so I would like to know how to prevent this.
Edited: If possible, please explain for newbie because I am very young beginner.
Try adding a variable like current timestamp to each url in its query string.
Just use querystring e.g. http://www.domain.com/style.css?version=1 for first version.
Now you update the stylesheet and you would like to reflact changes to all users browser who have cached version of old stylesheet. for this just change version querystring value to 1.1
e.g. http://www.domain.com/style.css?version=1.1
This works for javascript, css and all other files called in by your html page.
Also for all files like html, css, js, you can eTag header. More information can be found here.
http://www.w3.org/2005/MWI/BPWG/techs/CachingWithETag.html

Is it possible to ignore the Laravel Lang cache temporarily?

I built a translation system for fun which reads all trans()/Lang::get() calls in my app and presents them along with their current translations in the localisation files in resources/lang, so that an admin user can enter new translations which updates a single localisation file on the fly.
Everything works as intended, but there's one minor annoyance: every time the form is sent and the localisation file is updated, the page reloads (through a redirect()->route() call, not e.g. redirect()->back()), but most of the time, it still displays the old information even though the file has been updated properly.
If I refresh, the changes show up after 0.5-5 seconds, which makes me assume it's a cache issue. So the question is: can I trigger a language cache ignore while I'm in the translation system, or is there another and/or smarter way? I did try sleeping for a couple of seconds, but it made the user experience kind of crappy.
I've got the same issue.
I added in my controller sleep and info to extra refresh the page from js.
sleep(2);
return back()->with("refresh","yes");
and then in my view:
#if (session('refresh'))
<script>
location.reload(true);
</script>
#endif
I know it's a stupid solution but it works. If somebody know a better way to do it, write me a comment please.

Codeigniter Cache

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

Magento Block not rendering/Instantiating

I created a custom block (by creating a module and doing a layout update via an xml file), and the block is not rendering for some reason.
I have commercebug installed so i checked the layout xml for the page and it shows that it updated with the proper info, but when I go to the blocks tab it's not there (and not calling it)
this block rendered nicely on my local machine but on the staging server it doesn't work (even though i copied the files etc.)
I am a beginner so any help would be greatly appreciated.
Thanks in advance,
pesach
It sounds like you're saying you've successfully added some Layout XML to the page layout. If you could post that it would help people debug your problem better.
The next three steps to take are
Ensure your block type is correct
Ensure your template file (if you're using one) exists
Ensure the block you're inserting your custom block into will automatically render blocks (i.e. is a text_list block)
If you post the actual layout xml you've added the page layout, we'll be able to help with the items above.

How to place a banner on webpage with one application to all pages of a website

How can I place a banner on webpage with one application to all pages of a website?
One way of doing this is to put your banner into a file, then include that one on each of your other pages. This way, you only have to change the code in one place to update the banner site-wide.
So, a PHP example would be:
banner.inc.php:
<?php
// echo out banner here...
?>
Then, on your other pages:
include("banner.inc.php");
You can just create a header file that you include in all your pages, and include the banner code in it. The solution is pretty much the same in all languages. If your host allows server-side includes, you can even do exact same thing with (nearly) pure HTML. You can also do it with JavaScript pretty easily.
Do you have a global template for all your pages? Something where the basic structure of all your pages is defined while the specific stuff is filled into parts of the body? If you had something like this you could modify the global template to have the banner you want and it would show on all your pages.
Google "html templating" for more.
I recommend using master pages. That way if you have something that has to be changed globally across the project you only have to change it in one place. And they are really simple to use.
If your web server is IIS, and you know a smidge of CSS you can do this without perl, without touching any other files, but at the cost of some performance.
IIS allows you to insert an HTML snippet into anything served:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e27f918e-89a9-45a8-8604-2ad2ded09d64.mspx?mfr=true
If said footer file, had CSS which shoved it to the top, then you would get the behavior you are looking for.
Please note, that this is NOT an ideal solution, but it is a quick and dirty patch until you can go back and retrofit all of your pages with a master page or something similar.
If it really should be on every page of your site, I'd argue that it's part of the site design rather than the content itself. In this case, you are easily justified in setting a background-image in your css. Of course, you probably then still have to have some sort of place-holder element in your html, but at least you could update the whole site together.
Well, hopefully you would have designed the website so that if you need to change something globally, you can just edit a header or footer file.
If not, I would use Perl to go through all the files, and do a search and replace.

Resources