Welcome Guest, Not a member yet? Register   Sign In
Assets intermittently not displaying
#1

[eluser]Pinkiee[/eluser]
I decided for various reason to handle my assets through a controller, by using a <base> and adding three simple rewrite rules in to the routes.php

Code:
$route["([a-z]+).css"] = "assets/css/$1";
$route["images/(:any)"] = "assets/images/$1";
$route["scripts/(:any)"] = "assets/scripts/$1";

And then with in an "assets" controller it was just a matter of creating a method for each of the asset types. For example :

Code:
public function css($file)
{
    $this->output->set_header('Content-type: text/css');
    $this->load->view('skins/' . $this->skin . '/css/' . $file . '.css');
}

The scripts method is pretty much the same (differnt header) and the images method just uses the get_mime_by_extension($image); to work out the header.

The problem I am having is while the page will display correctly 25% of the time, the large majority of refreshs will reload the page with one or two images not loaded. Furthermore about 20% of the time the page will not load a CSS file.


Things I have checked:
* httpd
* removing a large amount of the css file
* compressing the css
* setting the expires upon the headers
* testing in differnt browers
* viewing the images/css separatly works correctly
* optimising the routing, removing any other routes not realated to the problem
* removing my base controller and using the default "Controller" Library



I was wondering if anyone else has either come across this problem or can think of why it would happen and how to fix it.

Thanks
#2

[eluser]slowgary[/eluser]
One thing about loading the assets in this way is that you won't get to see PHP errors if they happen in those calls. Have you checked the error_log? Nothing else I can think of.
#3

[eluser]Pinkiee[/eluser]
You were on the right track gary, it was based off of an intermittent output from the Session class which was being autoloaded. Thus the headers were not being sent correctly.

Once I removed the session class from the autoloader and instead placed a call to it from my controller, then set the assets to use the default controller, the problem was solved.
#4

[eluser]slowgary[/eluser]
Nice. Good work.




Theme © iAndrew 2016 - Forum software by © MyBB