Search code examples
phpzend-frameworkcachingzend-studiozend-server

Zend Server "Caching" of JS and CSS files


I'm running Zend Server in a CentOS VM on Vitrualbox and I'm having a problem with linked JS and CSS assets being "cached". I say "cached" because they aren't, in the true sense, being cached, but rather when I add content to a JS or CSS file they become corrupted and the changes do not appear. Instead the file is appended with a bunch of bad characters eg.

layout.phtml (zend framework template)

$this->headScript()->appendFile ('/js/admin/product.js', 'text/javascript' );

This renders:

<script type="text/javascript" src="/js/admin/product.js"></script>  

products.js

        //re-add scrolling handles
        scrollThumbs.reSortThumbs(ul);
        product.moveFileInput(ul);
    };
};��������������������������������������������������

If I remove content from the JS or CSS file the result is an incomplete file and not the addition of bad characters as outlined above.

I've turned off all forms of Zend caching and even turned off Zend Optimizer. I've deleted browser cache and tried several browsers.

I have ssh'd into the server and double checked the file and it is perfectly formatted and contains the changes. I've tried restarting Zend Server (/usr/local/zend/bin/zendctl.sh restart) and Apache (service httpd restart)

The only way to fix it is to restart the entire OS (reboot). Interestingly, if I remove the changes, it goes back to working correctly. I can only assume that there is some form of caching happening somewhere on the server side.


Solution

  • It turns out that it is a Virtualbox shared folder issue and not one uniquely related to Zend Server, but Apache in general.

    The fix came from Shared folder in VirtualBox for Apache

    Add EnableSendfile off to your vhost file eg.

    <VirtualHost *:80>
        DocumentRoot "/mnt/your/shared/dir"
        ServerName Default
    
        <Directory "/mnt/your/shared/dir/public">
            EnableSendfile off
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>