I have an application built in zf2, all the js, css, images are in the public directory. The js and css files which are needed in all the phtml files are declared in layout.phtml of Application module.
echo $this->headLink ( )
->prependStylesheet ( $this->basePath () . '/css/owl.carousel.css' )
->prependStylesheet ( $this->basePath () . '/css/owl.theme.css' );
<script type="text/javascript" src="/js/layout.js"></script>
<script type="text/javascript" src="/assets/bootstrap-fileupload/bootstrap-fileupload.js"></script>
<script src="/js/custom.js"></script>
And The files that are needed for a particular phtml file I include them in that file directly. I am using caching to cache images. But the problem here is that whenever I made some changes in my js or css files I have use ctrl+f5 to see the changes otherwise they are not reflected. Below are the configurations of my .htaccess file:
# Enable expirations
ExpiresActive On
# My favicon
ExpiresByType image/x-icon "access plus 1 year�
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
As you can see I have configured htaccess to cache only images but browser is caching js and css file automatically. I can do ctrl f5 but how can I tell my user to ctrl f5. On some searching I came accross asset management. I am thinking to follow this one Assetic Module. I have some doubts like how to use it to include js or css files in different phtml file? How much changes are needed to use it in existing ZF2 application ? Or Someone with better options ? If anyone who have implemented this earlier then please share some code snippets.