Guidelines on caching js, css, images

70 views
Skip to first unread message

Daniel Dimitrov

unread,
Mar 13, 2015, 2:49:19 PM3/13/15
to joomla-...@googlegroups.com
I'm trying to find any guidelines on where cached javascript, css & images should go. I've started using the cache folder for this with the following syntax:
com_mycomponent.javascript
com_mycomponent.css
com_mycomponent.images

Now I understand that the correct location for assets such as js, css & images coming with an extension is the media folder. However I don't think that the media folder is the correct location for any cached files.
I minify the javascript files on the fly. Having those 100s of js and css files in the media folder makes it difficult when you do backups - you should know that an extension is doing something like this and explicitly remove those folders from the backup. But users don't know this and I've found backups of users in the GB area where more than 80% were cached resources of few extensions...

The problem with the cache folder is that some users block direct access to it though .htaccess. So if you are serving resources from there, you won't be able to do that...

In my point of view - we should recommend using the cache folder for temporary resources such as minified js, css or temporary resized images.

What's your take on this?

Phil-Taylor.com

unread,
Mar 13, 2015, 3:21:11 PM3/13/15
to joomla-...@googlegroups.com
In my (quite considerable) experience with a wide variety of non-core extensions I have seen them all over the place and with total disregard to any "standard" document, assumed or otherwise.

We have 

/cache/etc....
/media/etc...
/tmp/etc...
/components/com_whatever/etc...
/templates/template_whatever/etc

The only one of the above that can be "flushed" from Joomla admin is the cache folder therefore if you want Joomla Admins to be able to flush the cached items they should be in there else you would have to roll your own way to delete/flush your cached items

I dont believe there are any hard and set rules... well Joomla doesnt dictate them... maybe it should, who knows... 

At the moment its a free for all - so be free! :-) 

Nils Rückmann

unread,
Mar 13, 2015, 3:52:47 PM3/13/15
to joomla-...@googlegroups.com
Unfortunately, there really is no standard. But IMO you should use media for fixed assets, as they can be overridden by templates. In fact, i'm also using the media folder for template assets, so all my customers can write their own overrides. If you want to cache something (like less-based css files or thumbnails), i would go for /cache.

Anibal

unread,
Mar 14, 2015, 6:56:51 AM3/14/15
to joomla-...@googlegroups.com
Hi,

Cache folder is usually restricted from direct access. It can be whitelisted, but it is an additional step in the installation workflow.

In my experience /media folder is the right place.

To solve the case of a growing folder of combined and minified files, a cleansing routine must also be implemented, along the delivery process.

Many extensions and templates have to deal with this common topic. Joomla could have an API to provide basic JavaScript and CSS optimization.

Regards,
Anibal
Reply all
Reply to author
Forward
0 new messages