Right now that scenario would generate different files.

The minifier is a replacement for a_include_javascripts, so it looks
at all the scripts that were requested via view.yaml, $response-
>addJavascript(), etc. and checks whether there is already a cached
minification of that complete set of scripts.

I think we'll find that most of the time there are a small number of
distinct sets that get used so this pays off fairly well. Also one can
further optimize it by being lazy and putting everything into view.yml
to ensure that there is a single javascript download, unless some of
the scripts are really ginormous.

However, it would not be hard for me to add a "bundles" option that
allows you to say "if any of the following scripts are requested,
satisfy them by delivering this complete bundle of scripts as a
distinct .jssgz file. If there is anything left over, deliver that as
a separate download." I think that could pay off and I'll put it on my
to-do list:

http://trac.apostrophenow.org/ticket/527

On Aug 15, 11:12 am, Johannes <johannes.schmitt...@googlemail.com>
wrote:
> I'm wondering what is going to happen in the following use case:
>
> You got two pages A and B.
> - Page A uses script C (10kb), and script D (20kb)
> - Page B uses script D (20 kb), and script E (1kb)
>
> Do you generate two different files for each page, or do you have any
> heuristics to decide when to combine, and when it's not worth it? In
> this case, only gzipping these scripts (thus leaving one file per
> script) should result in usually higher performance than generating
> two different, but combined files.
>
> Kind regards,
> Johannes
>
> On Aug 15, 2:04 pm, Tom Boutell <t...@punkave.com> wrote:
>
> > The cached versions are removed by 'symfony cc' and subsequently
> > regenerated by the next request. They are files in the web/uploads/
> > asset-cache folder, so they are not cached by the browser any more or
> > less aggressively than the original files in web/css, web/
> > apostrophePlugin/css, etc. would be. So the minifier doesn't change
> > the caching situation any one way or the other.
>
> > It might be worthwhile to take things a step further by versioning
> > them in the URL so that they can be given an infinite cache expiration
> > date, although this requires a database hit or perhaps a glob call
> > when outputting the pages that contain them. The code is a big step
> > forward as-is if you are using unminimized, uncombined CSS and JS and
> > has no negative impact on your existing caching issues, but we'll
> > think about next steps.
>
> > (I wonder what the performance cost of using a glob call would be
> > relative to a database hit? This article says 1,000 glob calls on a
> > directory with 400 files take about 2.2 seconds for the globs
> > themselves. In a directory that will only contain a handful of files,
> > that gives us an upper bound of less than 2.2 milliseconds, probably a
> > lot less. This was on an older Macbook Pro, not wildly unlike a server
> > in its single-CPU 
> > performance:http://www.phparch.com/2010/04/28/putting-glob-to-the-test/
> > )
>
> > As for where to get the code, it's in apostrophePlugin which is
> > readily available via the Symfony plugins site:
>
> >http://www.symfony-project.org/plugins/apostrophePlugin
>
> > The code lives in aHelper.php.
>
> > Make sure you check out the svn trunk of the plugin rather than the
> > stable branch of a tarball as this is new work not yet in a tarball
> > release.
>
> > On Aug 14, 12:00 pm, pghoratiu <pghora...@gmail.com> wrote:
>
> > > Hi!
>
> > > How do you solve the cache invalidation for these resources (in case
> > > they are cached on the client side)?
> > > Please post also a link to the sources.
>
> > > Thanks,
>
> > >     gabriel
>
> > > On Aug 14, 5:08 pm, Tom Boutell <t...@punkave.com> wrote:
>
> > > > We've committed a new CSS and JS minifier to the trunk of
> > > > apostrophePlugin. It's possible to take advantage of this even if you
> > > > don't need the rest of Apostrophe for your project.
>
> > > > Apostrophe now has a built-in CSS and JS minifier, similar to
> > > > sfCombinePlugin but up to date and easier to work with. All you have
> > > > to do is call a_include_javascripts and a_include_stylesheets in your
> > > > layout.php rather than the usual include_javascripts and
> > > > include_stylesheets.
>
> > > > Although we didn't start from sfCombinePlugin, which has not been
> > > > updated for about a year, we are not reinventing the wheel here.
> > > > Apostrophe now bundles the latest stable release of the excellent
> > > > Minify package by Ryan Grove and Steve Clay.
>
> > > > We're not using Minify's built-in server. Instead we are using the
> > > > Minify library classes to do the actual minification and integrating
> > > > these into our helpers for a native Symfony feel. That means that:
>
> > > > * When minification is turned on with app_a_minify, all CSS files
> > > > needed on a page are rolled into a single file
> > > > * Ditto for JavaScript
> > > > * The cache files are automatically reused if they already exist
> > > > * The cache files are automatically erased when you 'symfony cc' on a
> > > > particular server, as you ought to do when you deploy anyway
> > > > * Files that need to be loaded separately (for instance, they have IE
> > > > conditional comments) are still loaded the traditional way
> > > > * Files that need to load together as a group because they have the
> > > > same script tag options (for instance, print stylesheets) are merged
> > > > to a separate cache file from the rest
> > > > * When app_a_minify_gzip is turned on, minimized CSS and JS files are
> > > > automatically gzip-compressed in advance when they are generated (the
> > > > necessary .htaccess directives to allow your server to support this
> > > > are in the trunk sandbox .htaccess file, take a look - all web
> > > > browsers support this so it's a big win)
>
> > > > Dead simple and very effective.
>
> > > > With app_a_minify and app_a_minify_gzip both turned on, the logged-out
> > > > view of the Apostrophe sandbox now receives a "B" grade from the YSlow
> > > > plugin. Those who are familiar with YSlow know that a "B" is extremely
> > > > hard to get. YSlow dings you for every little infraction, including
> > > > the use of images that are not CSS sprites and so on. Our former score
> > > > was an "D"
> > > > on an "A" to "F" scale (a "C" if the server is configured to gzip
> > > > everything on the fly, but that takes more CPU than app_a_minify_gzip,
> > > > which runs only at caching time).
>
> > > > To use this in a project in which you don't otherwise want Apostrophe
> > > > (although I obviously think you should consider using it!), you'll
> > > > want to tell Apostrophe to disable its built in routes:
>
> > > > app_aMedia_routes_register: false
> > > > app_a_routes_register: false
>
> > > > Turn it on in app.yml (for testing, do it under 'all', but later
> > > > probably just 'prod' so you can still easily debug JS and CSS):
>
> > > > all:
> > > >   a:
> > > >     minify: true
> > > >     #Optional but a huge win, requires appropriate Apache
> > > > configuration and zip support in PHP
> > > >     minify_gzip: true
>
> > > > And just start calling a_include_javascripts and a_include_stylesheets
> > > > instead of include_javascripts and include_stylesheets in your
> > > > layout.php.
>
> > > > To make the gzipped CSS and JS files work, your PHP must have zlib
> > > > support (check your phpinfo), and Apache must be configured to serve
> > > > .cssgz and .jsgz files correctly (you can do this in your .htaccess
> > > > file):
>
> > > > AddType text/javascript .jsgz
> > > > AddType text/css .cssgz
> > > > AddEncoding x-gzip .jsgz .cssgz
>
> > > > If you don't want to do that, you can leave app_a_minify_gzip turned
> > > > off, but it won't be as awesome.
>
> > > > symfony cc and go to town.
>
> > > > That's it - no database tables needed, no schema changes.
> > > > Note that web/uploads/asset-cache needs to be writable by Apache
> > > > (project:permissions should take care of this).
>
> > > > Enjoy!
>
> > > > --
> > > > Tom Boutell
> > > > P'unk Avenue
> > > > 215 755 1330
> > > > punkave.com
> > > > window.punkave.com
>
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to