Should résumés be attached in a mail to a professor? Say there is a student who writes a mail to a professor asking for a PhD vacancy or a RA-ship position. Should he attach his résumé in a mail to a professor?

I have had contradictory viewpoints on this. Some people ask not to attach résumés in such mails to professors, saying such mails go straight to spam. They instead prefer having a webpage and providing a URL. This is tough, as students (esp. undergrads) do not have a lot to share on a website. Moreover there is a contradiction: if a professor cannot view a résumé in her browser, what is the guarantee she would visit a website and click each of the sublinks? Looks more implausible to me.

There are others who advise applicants to provide a brief bio instead of a résumé or a URL. Again this could turn out awkward: in a bio, "I did my bachelor's in XYZ University" is fine, but "I was fourth in the Department during my bacheor's" looks out of place.
I slightly prefer attachments.  The problem is that I'm reluctant to reply to e-mails asking for more information, or even to show up on server logs following links, because it may be interpreted as a sign of interest.

Like most faculty members (at least in technical areas), I get enormous numbers of junk e-mails regarding PhD positions or summer research.  The general pattern is that they are form letters sent to large numbers of people, almost all of whom ignore the letters.  If anyone replies in anything but the most discouraging way, then it inspires a potentially lengthy e-mail exchange that will probably just waste everyone's time.

This is a real problem, and I don't know what to do about it.  It's not really fair, but right now the burden is on applicants to stand out from the junk e-mails.  In particular, your e-mail should provide compelling proof that you spent at least as long thinking about it and writing it as you expect the faculty member to spend on it.  If it looks like it could be a form letter with the professor's name and research topic pasted in, then I'll ignore it, as will many other people.  [I should point out that I work in a department with centralized admissions, so I cannot accept students on my own.  This is explained on my web page and the department's.]

For example, a clearly personalized e-mail that discusses the professor's research in detail is good.  Keep in mind that plenty of people are trying to cheat with this.  For example, I regularly receive e-mails saying something like "I found your paper X fascinating when we read it in our seminar", with no further details.  This looks like a form letter, and there have been a couple of times when I've received e-mails from the same sender that were identical except for having different paper titles pasted in, with no indication that they had previously e-mailed me about another paper.  Maybe a few e-mails are genuine, but they sure look like lies.

So when I get an e-mail regarding PhD admissions or summer research, I'm very skeptical that it's more than spam.  There's a five or ten second window to convince me that it's different from the other e-mails, before I set it aside.  If it looks promising, then I'll read further, and I'm a little more likely to do so if any information I need is available right there.  So I'd recommend attaching whatever is needed.