Jump to content

requinix

Administrators
  • Posts

    15,071
  • Joined

  • Last visited

  • Days Won

    414

Everything posted by requinix

  1. The only times I've seen people say to not use ETags are: a) Conflict between it and other caching headers - solution is to fix the headers, or use only one set of them b) Incorrectly configured backing information - solution is to fix the backing information c) Situations where ETags are not the best solution, or don't behave in the way that the caching requires - solution is, obviously, to use what's better With a quick search around I see a lot of people saying to use them, so... any specific arguments against that you'd want me to address?
  2. ETags is built-into Apache. I'm surprised your server isn't configured to send them already, but whatever you can turn them on with that FileETag directive. As for more information... I really don't know. Wikipedia is generally pretty good (at least with technical information). If MDN or MSDN have articles on it then I'd recommend those. This has nothing to do with time. Time does not factor into any part of it. 1. The client requests the file for the first time. 2. The server calculates an identifier for the file. Like combining a few pieces of information together and hashing it. Make sure that information will accurately reflect whether a file has changed or not. 3. Server sends the file and the identifier. Client caches the file and the identifier. 4. Client requests the file for the second time, but sends the identifier it had learned previously. 5. Server calculates the identifier again; a) If the identifier doesn't match then the file has changed, the server replies with the file and the new identifier and the process starts over b) If the identifier matches then the file has not changed, the server replies without the file and the client reuses what it had cached previously Client always re-requests the file every time. Server always checks if the file has updated before replying. Client only receives the file if it has changed. Otherwise yes, you should be able to drop that code into a .htaccess and have it work.
  3. Honestly, it's felt like that sometimes to me too. It's possible there's a problem somewhere but the configuration definitely says 15 minutes. At least where I saw - maybe there's an override somewhere I don't know about?
  4. Expires sucks. The problem is that it instructs the browsers to not even try to retrieve content until the time has passed. Don't use it. Remove all that stuff. Use ETags instead. The server will send a hash with the content that (should) only change when the file changes. The client will keep trying to request the file, but will send the last hash it knew about. Then the server will reply with either (a) yes, the file has changed and here it is with the new hash, or (b) no, the file has not changed so use what you have cached. It doesn't save as much bandwidth as Expires does (there's still the overhead for each request to check the hash) but it saves you the hassle of dealing with query strings and such. <Files ~ "\.(css|gif|jpe?g|js|png)$"> FileETag All </Files> You may need to unset other caching headers, mostly just Cache-Control, Expires, and Pragma, if they're being sent automatically.
  5. The window is 15 minutes. The idea is to have a long enough window for people to correct accidental mistakes, but short enough that someone can't go in and change the content of their post after people have read and possibly replied to it.
  6. What are you using? Expires? Expires sucks. How about ETags? ETags are more-or-less perfect, provided the backing information is chosen well (defaults are normally fine). We're saying two different things. But I've tried to get us on the same wavelength and that isn't working, so I'm bowing out of this argument. I stand by my "not using the right directives" comment. And see above replies. A random number is more than you need. The time is sufficient. <?php $time = time(); $content1 = '<a href="http://example.net" title="Example 1" target="_blank"><img src="http://example.com/gallery/image-1.png?' . $time . '" alt="Image 1" width="300" height="250" class="gallery-image"></a>'; $content2 = '<a href="http://example.net" title="Example 2" target="_blank"><img src="http://example.com/gallery/image-2.png?' . $time . '" alt="Image 2" width="300" height="250" class="gallery-image"></a>'; $content3 = '<a href="http://example.net" title="Example 3" target="_blank"><img src="http://example.com/gallery/image-3.png?' . $time . '" alt="Image 3" width="300" height="250" class="gallery-image"></a>'; $content4 = '<a href="http://example.net" title="Example 4" target="_blank"><img src="http://example.com/gallery/image-3.png?' . $time . '" alt="Image 4" width="300" height="250" class="gallery-image"></a>'; $content = array($content1, $content2, $content3, $content4,); shuffle($content); ?> <?php print $content[0] ?>
  7. 1. Then you aren't using the right directives. It's true that browser's don't have to obey the settings, but when done correctly they will obey the headers when they are supposed to. 2. If each image in the list corresponds to one unique image then you do want the images cached. What you don't want is the HTML producing the random image to be cached. Which is entirely different than what you're going at. And it shouldn't even happen in the first place with PHP scripts. Which leads me to 3. Have you confirmed that there is an actual problem here? Or do you think/assume there is a caching problem and you're trying to fix it preemptively?
  8. It's could be... Look at the traffic in detail to tell what they're doing. But blacklisting an entire IP range should be (1) a last resort (2) after you've determined there's no other way (3) to prevent people from causing problems with your system.
  9. You're trying to fix the symptom. Fix the actual problem: your server is telling browsers to cache the images. Is this all online somewhere we can see?
  10. counter = 1 for each image { if counter = 1 { output div code with inline-block } else { output plain div code } output image code output closing div counter++ }
  11. Why stop it? Is there a problem? Traffic from Amazon (AWS) could be VPN servers or proxies that people need to use.
  12. Using just vanilla Javascript? It's passed to the function as the first argument. element.addEventListener("change", function(e) { e.preventDefault(); // ... });Unless you want to be cross-browser compatible, in which case don't use vanilla Javascript.
  13. You can do SHOW CREATE for pretty much anything in the database. Like SHOW CREATE FUNCTION whateverfunction. It'll return a string with SQL. To dump the database I assume you're using mysqldump? Try its -R/--routines option.
  14. To answer the original question, use event.preventDefault().
  15. Go to the kitchen, make yourself a sandwich, eat the sandwich, then come back and read your code very carefully. if atts has the property then { tell me that the property was removed } else { tell me that the property was not removed }Protip: delete has a return value for whether it deleted the value.
  16. .extend() is basically a .append() that works with arrays. Assuming you're using $to_checksum as a string instead of an array, $to_checksum = "\x68\x32\x01\x7b\x01"; // to_checksum.extend(struct.pack("<h", gif_len)) // < = little-endian, h = signed short (2 bytes) // php's pack() doesn't have a little-endian signed short code, so convert signed to unsigned and use 'v' $to_checksum .= pack("v", ($gif_len < 0 ? 65536 + $gif_len ? $gif_len)); $to_checksum .= chr(packet_num) . chr(last_packet_num);I'm a bit unsure of that last line.
  17. Make sure your file is named *.php, that you are using full <?php tags (and not just ), and that you have PHP installed properly.
  18. Basically, a class should represent a noun. It is responsible for a particular thing. Inside the class are methods and those represent verbs. Those methods perform actions. $noun = new Noun(); $noun->verb(); Registering and logging in are verbs. Ask yourself "what is doing the registering and what is doing the logging in?" The answer is a user. (Which is a noun.) So there should be a user class with methods to register and to log in. Two answers:1. Now you're thinking about models. A model is a class, which means it's a noun. 2. Does it make sense to "create" a registration? "Create" a login? Not really. Registration is the act of creating a new user. So there should be a class for the user model which has CRUD operations. Logging in doesn't really impact the model... unless you wanted to record login time or last activity, then that would have an impact of updating the user record. But otherwise you're looking up information, which is part of CRUD. Depends. Most of the time a database class represents a database connection (a noun), and has methods to help you do stuff so that you don't have to do everything manually via PDO. Such asa) Abstracting the database connector away (which PDO kinda does already) b) Retrieving database credentials so the rest of your code doesn't need to know c) Helper methods to make some operations easier, like executing a SELECT and returning the results in an array Well, what kinds of things does a user do? We've already covered "a user can register" and "a user can log in". "Single" is about making sure a class isn't responsible for multiple things that don't make sense to combine. Like a class that does database operations as well as handle file uploads. If you can say "this class is responsible for " then you're probably okay. I could argue in favor of doing that, but practically speaking 1. There aren't too many operations involved with passwords: create new random password, create hash of password, verify password 2. Often those operations are part of a larger operation: create a new random password because the user forgot theirs, or create a hash of a password because the user is changing theirs, or verify a password because a user is trying to log in 3. There's not much code involved 3. Pretty much everything you do with a password has to do with a user, for which you already (hypothetically) have a class, so you might as well put the password code in there
  19. The "string" type will be coerced to the "String" type, which does have methods and properties.
  20. Don't let Jacques bother you. He's like that to everyone. One way or another, what you're trying to do can be possible. How much of this code is yours? Or put another way, how familiar are you with the PHP involved in this process and are you able to edit it?
  21. The URL is only the path portion. You probably don't need to concern yourself with the domain, so really all you need is to match the index.php and add a condition for the query string. <rule> <match url="^index\.php$" /> <conditions logicalGrouping="MatchAll"> <add input="{QUERY_STRING}" matchType="Pattern" pattern="^aggrement$" /> </conditions> <action type="Rewrite" url="index.php/aggrement" appendQueryString="false" /> </rule>I think. That does a rewrite - the user doesn't get redirected. If you want a redirection then use a "Redirect"-type action. Reference
  22. I know. I was anticipating a "what is domdocument" reply.
  23. What does your web.config look like?
  24. 1. Look at the syntax highlighting near the beginning of the code. See how the echos are black but the exit is green? Something changed in between them... 2. Those echos aren't using correct syntax for strings. Read this to learn what kind of syntaxes are allowed.
  25. if( $_GET['stepaa'] || $_GET['stepab']|| $_GET['stepac'] ) { echo "$_GET['stepaa']"; echo "$_GET['stepab']"; echo $_GET['stepac']"; exit(); } ?> Drop Down Draw Draw outline for Enhance Make Drop Down an Oval Ovals a circle circles arms hands feet foot lower face belt ears ear eyes eye brows nose lips retinas shoes boot wings wing beak tail body hairs waist leg hip fingers horn horns weapon book table crown ribbin locket bangles head mouth tongue necessary improvements to finish , . & Drop Down an Oval Ovals a circle circles arms hands feet foot lower face belt ears ear eyes eye brows nose lips retinas shoes boot wings wing beak tail body hairs waist leg hip fingers horn horns weapon book table crown ribbin locket bangles head mouth tongue necessary improvements to finish. Next time, please post short code like yours directly into the post. Many people don't like having to download attachments.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.