-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple servers and CDN support #17
base: master
Are you sure you want to change the base?
Conversation
…nd etag. if the serverFarm config is set to true, when combining files press will not generate a tag with the hash code but instead with the list of names of compressed files. this way wheh the JS request gets to a server that doesn't have the key in the cache, press can still build the list of requested files and return them.
when working with a CDN sometimes you want a new version of the file to refresh the CDN version. by adding the timestamp to the request it will happen.
…, and not compress this is good for adding cache buster to JSs that are not compressed
Hey, thanks for your interest in the plugin. I've been trying to track down that rename bug for a while now, it seems so obvious now that you've pointed it out. Thanks! I had a few questions about your pull request:
These are just some little issues I noticed:
Thanks again for you interest |
Hi, OK, I didn't think all my pushes will be joined automatically to the pull Now for the other stuff - let me first explain the motivation for the I still want press to work on optimum - that is store the compressed files The second issue is working with a CDN. With the combined script there's no About the ETag - it looks like that's the way play handle this, I thought it Does it make more sense now? On Mon, Sep 26, 2011 at 5:10 PM, dirkmc <
|
Ah ok I think I understand what you're saying. The reason the request key is a hash, instead of the original list of filenames is because if you have a large number of files, then the request key might become longer than the maximum limit for a GET request. That's why I use the cache to store the list of files, then retrieve it using the hashed request key. If the request key is not found in the cache, then I think there is a problem with the cache implementation. The default cache implementation only works on a single server, but if you use memcache then it should work across multiple servers. Note that you can still store the compressed file on disk - if the compressed file is not found on the current server, it will be generated on the fly. Regarding the single-script issue, I think if we set the last-modified/eTag signatures correctly the browser should be able to figure out if it needs to request a new copy of the file. |
Using memcached for this is not really a good measure, you pay the I know the length of the key is a potential problem with this kind of About the single-script, setting the last modified won't do. The CDN needs On Mon, Sep 26, 2011 at 6:20 PM, dirkmc <
|
I can see what you mean about not wanting to pay the performance hit of an extra network request, and not wanting to set up a memcached cluster just for storing the set of file names. However I don't really like the idea of possibly breaking the GET limit either. I think for the majority of users the way press currently works will serve them better. I can see why you need to customize it in your case though. |
That's why it is enabled only by setting the press.serverFarm=true. On Mon, Sep 26, 2011 at 7:20 PM, dirkmc <
|
Right. I'll take a look at in including it when I get a chance |
Thanks again for taking the time to improve the plugin |
Cool. I think this can be useful to a lot of people. Thanks for supporting it! On Mon, Sep 26, 2011 at 7:32 PM, dirkmc <
|
when working on multiple servers we need to make sure the request key holds the files in the order requested. we can't ensure the order implicitly as the tag calls are not by order. so the user needs to explicitly set the order in the tag
1. enforce specifiying the file position when serverFarm is enabled - otherwise we can't ensure right compression order 2. don't try to reorder the file array on save since the key is ordered 3. break the script tag to several tags if the combined file name is too long
Hi, I've added some additions to the changes I made. While testing on a multi-server setup I noticed there was a problem with the order the JS files are combined. This happened when a server that did not serve the HTML got the JS request and created it on the fly. Since originally press ordered the files after the script tag was written, the combined name was not in the right order. I did not see anyway around it but to enforce the user to explicitly specify the order in the script tag. So now, if you activate the serverFarm mode, you have to specify the pos parameter in the script tag. Then the combined name will be generated according to the ordered files (sorted by the positions you give and not the order on the HTML). Also, since in this mode we're keeping the order like that, there's no point anymore in searching the response for the extracting tags for getting the order - so in the serverFarm mode I'm skipping that. (And it actually cuts the performance overhead of doing that when generating the HTML). Another improvement I added deals with your rightful concern about the length of the combined key. So now if the key is too long I break it up and create several script tags (as needed). So if you try to combine many files together and the name gets long it might create two combined files with less files in each. In most cases that won't happen, but it ensures JS requests won't break if you don't pay notice. |
Yes you're right that one of the reasons that the file list is stored in the cache is so that the order of the files can be detected after the output has been generated. I should have mentioned this in our conversation yesterday. This is something that I'd really rather not change, it's part of the reason that I originally developed the plugin. There is another plugin on which press is based called Greenscript that works more like what you're talking about. |
I've seen Greenscript but I already dived into press so I continued with I understand the motivation for keeping it in cache but it's not valid if
On Tue, Sep 27, 2011 at 11:52 PM, dirkmc <
|
Hi, I tried to work with this branch since we need multi-server support, but it did not work - the compressed JS is malformed (this is the copy-paste from the chrome console, sorry for the poor formatting):
Could it be that scripts that should not be compressed (marked as |
Hi, I haven't noticed a problem with the compress:false attribute. We're using On Fri, Nov 18, 2011 at 1:27 PM, Manuel Bernhardt <
|
Indeed it was the CSS. See the pull request on your fork. @dirkmc getting this into a release would really be useful. |
Fixing rendering of link tag; setting content-type
Fixing path to links/scripts when press is turned off and the base path is /
… query strings. Added versioned-file tag for routing non-JS or CSS files through CDN. (See readme).
Does this path allow being able to automatically/ transparently upload compressed assets to a CDN (say S3 / Cloudfront) as part of the Press-build process? If so, great! If not, then what IS it for? |
It's not about uploading content to S3 but rather about routing your On Thursday, December 08, 2011 4:23:22 PM, gbrits wrote:
|
Ok but let's take the example of Cloudfront. It doesn't support query-strings which you nicely support, so my HTML would Thanks for painting a clear picture. Op 8 december 2011 15:42 schreef Rotem Hermon <
|
body
|
Ahh yes that explains it. I didn't know of the custom origin feature. Many Op 8 december 2011 16:00 schreef Rotem Hermon <
|
Hi gbrits, Could you tell us what the status is of this pull-request? Are you going to merge it, ifso, when? Or why not? Thanks in advance, |
Oh.. I guess I should have asked that to dirkmc! :-) |
Hello, to see why I'm not going to merge it you can see the conversation above. |
I'm working on adjusting press to a server farm scenario (multiple servers - currently press doesn't really support that well).
While working on it I encountered 2 small bugs: