Preventing 200 (Cached) responses - django

I just deployed a Django app with majority of the front-end code in Javascript files. The problem is, whenever I make an update to my JS files, that is not reflected on if someone opens the page, since they get a '200 (Cached)' response, and are getting the previous version of the Static file. A CTRL-F5 fixes this of course.
What would be the best way to deal with this issue? Where would a problem like this be solved?
Headers in the Django response?
Some Apache config (since the static files are server directly from
Apache)
Something else?
I don't want to go through the route of renaming files after each change, it doesn't seem like a clean solution for me. Any proper technique of achieving this?
One thing that I noticed, the 200 (cached) response that I get has these among the headers:
Expires:Fri, 28 Nov 2014 04:11:29 GMT
Last-Modified:Sun, 28 Sep 2014 19:43:58 GMT
The Last modified infact should be around 29 Sep 2014 09:14 GMT. Could it be something to do with the Expires header? If yes, how should I set expires to, maybe, a day or less in the future? Again, this has to be done via Apache I presume?
NOTE: Performance gain/loss due to caching is absolutely not a concern here.

Take a look at using WhiteNoise or django-compressor to handle this.
Most production deployments of Django minify the CSS/JS at first fetch-time, and name the resultant file using a checksum. That way, the files can be cached forever, since if they're changed, a different filename will result.
Since there are apps available for this already, hopefully this won't cause you too much trouble.

Related

Coldfusion 2021 Update 5 breaks xml

I just applied update 5 and now I am getting XML errors:
"Error","ajp-nio-127.0.0.1-8020-exec-10","10/13/22","11:28:42","Medlists3","coldfusion.runtime.CFPage.XmlSearch(Lcoldfusion/xml/XmlNodeList;Ljava/lang/String;)Ljava/lang/Object;
https://helpx.adobe.com/coldfusion/kb/coldfusion-2021-update-5.html says
CHANGE IN XML
If the XML path contains a forward slash or backslash, it will be
blocked. The flag, coldfusion.xml.allowPathCharacters, must be set to
true to allow the same.
But I don't know where to make this change.
This question was asked on CFML Slack and it was said that you needed to manually clear all .class files from disk since the bytecode is not binary compatible.
A legacy Fusebox 5 coldfusion application got this exact error. Following up on gabriel's note: after deleting the contents of cfclasses, I had to restart the Coldfusion 2021 Application in services (Windows Server 2019) in order for the contents of cfclasses to refresh. After the restart, the application worked as normal.
Adobe added the following comment for the patch notes for CF2018 Update 15, but they said that this shouldn't be an issue in ColdFusion 2021-
https://helpx.adobe.com/coldfusion/kb/coldfusion-2018-update-15.html
--
Known issues in this release
If you encounter the following error message, clear the classes in <CF_HOME>/instance/wwwroot/WEB-INF/cfclasses.
"coldfusion.runtime.CFPage.XmlSearch(Lcoldfusion/xml/XmlNodeList;Ljava/lang/String;)Ljava/lang/Object; The specific sequence of files included or processed is: \<filepath>, line: 34 "
java.lang.NoSuchMethodError: coldfusion.runtime.CFPage.XmlSearch(Lcoldfusion/xml/XmlNodeList;Ljava/lang/String;)Ljava/lang/Object;
If the Uninstall button is disabled on Update 15, uninstall the
update using the uninstaller.jar present in the hf-updates folder.
your application uses the functions XmlSearch and XmlTransform,
you'll have to recompile the files after applying Update 15.
--
I added the variable "-Dcoldfusion.xml.allowPathCharacters=true" in Java JVM arguments and it worked.
In your Coldfusion Administrator, under Server Settings, Java and JVM, in the JVM Arguments box, append the following to the end (make sure there is a space after the last entry:
-Dcoldfusion.xml.allowPathCharacters=true
Then restart the CF Service.
Took care of the problem for us.

How to enable gzip compression instead of brotli compression on OLS + DA?

I'm using Litespeed plugin for wordpress (From LiteSpeed Technologies), with a litespeed server, and despite what I do, it is not compressing javascript and css, and there's no option in the plugin for setting up "js & css" by the way. I already tried using other plugins, so I don't think the problem is the plugin, it's something in my server. I tried editing the following files usr/local/lsws/conf/httpd-tuning.conf and /usr/local/directadmin/custombuild/configure/openlitespeed/conf/httpd-tuning.conf
Changed the compression level, and yet I can't put this thing to compress. Yes, it is working, but it's only compressing text and html.
Even after changing the headers in the files from text/*, application/x-javascript, application/xml, application/javascript, image/svg+xml,application/rss+x$
to
text/*, application/x-javascript, application/xml, application/javascript, text/html, text/css, text/plain, text/xml, text/x-js, text/js, text/javascript
it still will not work.
Yes, I restart lightspeed every time I make changes, I can even see from the litespeed server administration that the new headers were applied. I believe it might be something else. I saw someone saying he said the same problem and his problem was the wildcard (besides the headers), but I don't know what that means.
For OLS, you can either enable gzip or brotli compression. Please refer to https://openlitespeed.org/kb/using-gzip-brotli-compression/. Since you are using OLS on DirectAdmin, you have no ability to modify the value by logging in to OLS admin console(That's because DA's implenmatation of splitting conf files, you will need to modify the server level or virtual host level directly by adding directive(brStaticCompressLevel 0) there. By the way, question title is better to change to: (not about caching at all, it is about )"How to enable gzip compression instead of brotli compression on OLS + DA" to avoid confusing.

Configuring Jetty to do console-capture and requestlog to a directory outside of jetty.base?

Looking at the docs, all the logging paths specified for console-capture and requestlog are relative to jetty.base, normally in $jetty.base/logs . That's ok for many purposes but, I really want logs to go into /var/logs/jetty , just like a lot of other processes would do. I've tried setting this in console-capture as /var/log/jetty, but that just tries to save log files in $jetty.base/var/log/jetty, which isn't what I need.
Is there some way to do this? I'm looking for the simplest possible approaches to saving logs. This is the last thing I need to do before my Jetty installation is fully in production. Overall it's been great. This is all with Jetty 9, latest release, on Ubuntu.
Start by not using console-capture.
You have progressed beyond the limited scope of console-capture with your requirement.
You'll want a formal logging framework, pick one, like "logback" (which the Jetty devs recommend), or java.util.logging, or log4j.
Use one of the logging-* modules to setup Jetty's server classpath to start using that logging library.
Now configure that logging library (example: if you are using "logback", the file ${jetty.base}/resources/logback.xml is what you configure)
Finally, configure your access logging to use slf4j.
Boom, all of your logging is now going to your logging library of choice, and it's configuration can be used to slice / dice / roll over / filter / etc the logging in any way you want.
You can have it split into different logging output files, combine them into one, roll on different rules (size, number of lines, duration, time, etc).
Definitely made some progress on this. For some reason, console redirect was taking the absolute path correctly while the request logger was not. For that, I made my configuration relative: ../../../var/log/jetty
This seems like a clunky way to do it but it does seem to work. I'm still getting a failure on startup but weirdly enough it's running fine and I don't see exceptions so I need to figure that out now.

Is there a way to stop ColdFusion 11 from caching Fusebox circuit.xml.cfm files?

Is there a way to stop ColdFusion 11 from caching Fusebox circuit.xml.cfm files?
I have to restart the coldfusion service every time I make a change to a fuseaction file and it's getting tiring.
There are 2 settings in play here. One is "trusted cache" - a setting in the CF admin that does not "check" for a modification once a class has been compiled. You can turn trusted cache off and CF will begin to check for modifications.
The second (and more likely) setting is "parsed" setting. This setting actually saves all your include files into a "parsed" directory and compiles the from there. You can try adding the following to your URL:
Fusebox.parseall=true or alternately Fusebox.loadclean=true - one of these might work.
Finally there is a "mode" setting you can modify to "development" from "production" - that will cause the whole thing to be reparsed.
This is from memory - but maybe it will be enough to get you going. good luck! :)

Where did the C (and C++) SNIPPETS library go?

Once, there was this awesome SNIPPETS library of C (and C++) code. I used it from 1995 on, but its origin is much older and it was updated until at least 2007. From time to time, I found that I needed a piece of code not from a library, but something I could cut and paste into my own projects.
To my horror, it's now gone. There are traces of it, dead links on SO for instance.
Can anybody find me a mirror, or an archive of it? I had an early version on my harddrive for years, but not any more.
Unfortunately, Bob Stout (the guy who put it together and was ultimately its sole maintainer) died in February; when the registration on the site's domain expired, it appears that nobody renewed it. As far as I know, the site worked up until then, so it may still be there in the servers, just with no registration to make the name visible. If you could find a way to get ahold of him, Jon Guthrie would probably be the person who could get it up and running again (IIRC, he was largely responsible for putting it up on the web in the first place).
I believe all the "released" versions of Snippets are available from IFDC FileGate in the PDNCEE area. If there's enough interest, I could probably sort out the code that's still reasonably interesting from the basically-obsolete (purely MS-DOS), and put it up on Github or SourceForge or some such.
Other mirrors of the (1997) version of Snippets:
http://www8.cs.umu.se/~isak/snippets/
http://www.brokersys.com/snippets/
TL;DR
Full github mirror of the code (Edited to point to github site, since first mirror died.)
Since your ServerFault question was off topic, I thought I'd post this here;
*puts on detective hat*
Well DNSHistory.org reports the domain snippets.org used to point to '206.251.38.37' up till 2011-04-02 (When did the domain go?)
Using CURL to send the 'host' header to that server;
[samr#ocelot~]$ curl -I -H "Host:snippets.org" http://206.251.38.37/
HTTP/1.1 200 OK
Date: Thu, 24 Nov 2011 15:12:16 GMT
Server: Apache/2.2.9 (Debian) PHP/4.4.4-8+etch6 mod_ssl/2.2.9 OpenSSL/0.9.8g
X-Powered-By: PHP/4.4.4-8+etch6
Content-Type: text/html
gives us a response. Next step, what does that page look like?
Well just getting the HTML and opening it in lynx;
[samr#ocelot~]$ curl -H "Host:snippets.org" http://206.251.38.37/ > snippets.org.html
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10319 0 10319 0 0 29500 0 --:--:-- --:--:-- --:--:-- 52583
[samr#ocelot~]$ lynx snippets.org.html
Gives the wonderful response of;
SNIPPETS sponsors [MicroFirm.gif] Firmware, system, and sensors
development [Sponsor.jpg] Click here to learn more [dmlogo.gif]
"Free C/C++ Compilers" [188x44_bss14.jpg] "High-Performance Version
Control"
[logo.gif]
Free educational resources on the Internet
______________________________________________________________________________________________________________________
Thursday, 24-Nov-2011, 15:13:22 GMT
Last modified: 01-Apr-2007, 05:50:42 GMT
395594 visitors since 15-Jul-2002
__________________________________________________________________________
Mission:
SNIPPETS.ORG is dedicated to providing free informational and
educational resources on the World Wide Web. Currently, the two
principle topics are programming and do-it-yourself (DIY) audio.
The fields covered by SNIPPETS.ORG are generally technology and arts.
As soon as enough free material is collected, new sections will be
added related to photography and digital imaging.
The one common factor in everything you'll find on this site is
that it's all free. Programming source code is free. Tools and
utilities are free. And, of course, information is always free.
While SNIPPETS.ORG provides many links to commercial sites, it is a
not-for-profit operation - nothing here is for sale! If you wish
to contribute content, information, or entire web sites to
SNIPPETS.ORG, please contact me.
[snip]
So to answer your question, the domain used to point to '206.251.38.37', and the site (appears to) still exist.
Next thing; mirroring. The wget tool provides a --mirror flag to recursively download a website to a directory, which looks to be just what we're after.
Started creating a mirror on my home server, but here's the command I'm using;
wget --header="Host:snippets.org" --mirror -p --convert-links -P ./snippets.org/ http://206.251.38.37/
Then I extracted the files from the code directories and uploaded them to my mirror site http://mirror.rmg.io/snippets.org/
embedded.snippets.org reports as 'down for maintenance' so couldn't be spidered.
The link you point to is not dead; it's alive at archive.org: http://web.archive.org/web/20080217222203/http://c.snippets.org/
Now, the latest copy of the SNIPPETS archive as found from archive.org, lives on at Github.